1 ; RUN: opt < %s -slsr -gvn -S | FileCheck %s
2 ; RUN: opt < %s -passes='slsr,gvn' -S | FileCheck %s
4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-unknown-linux-gnu"
7 ; Do not perform SLSR on &input[s] and &input[s * 2] which fit into addressing
9 define i32 @no_slsr_gep(i32* %input, i64 %s) {
10 ; CHECK-LABEL: @no_slsr_gep(
12 %p0 = getelementptr inbounds i32, i32* %input, i64 0
13 %v0 = load i32, i32* %p0
16 %p1 = getelementptr inbounds i32, i32* %input, i64 %s
17 ; CHECK: %p1 = getelementptr inbounds i32, i32* %input, i64 %s
18 %v1 = load i32, i32* %p1
21 %s2 = mul nsw i64 %s, 2
22 %p2 = getelementptr inbounds i32, i32* %input, i64 %s2
23 ; CHECK: %p2 = getelementptr inbounds i32, i32* %input, i64 %s2
24 %v2 = load i32, i32* %p2
26 ; return v0 + v1 + v2;
32 define void @no_slsr_add(i32 %b, i32 %s) {
33 ; CHECK-LABEL: @no_slsr_add(
35 ; CHECK: add i32 %b, %s
36 call void @foo(i32 %1)
38 ; CHECK: %s2 = mul i32 %s, 2
40 ; CHECK: add i32 %b, %s2
41 call void @foo(i32 %2)
45 declare void @foo(i32 %a)