1 ; RUN: opt < %s -passes=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(ptr %input, i64 %s) {
10 ; CHECK-LABEL: @no_slsr_gep(
12 %v0 = load i32, ptr %input
15 %p1 = getelementptr inbounds i32, ptr %input, i64 %s
16 ; CHECK: %p1 = getelementptr inbounds i32, ptr %input, i64 %s
17 %v1 = load i32, ptr %p1
20 %s2 = mul nsw i64 %s, 2
21 %p2 = getelementptr inbounds i32, ptr %input, i64 %s2
22 ; CHECK: %p2 = getelementptr inbounds i32, ptr %input, i64 %s2
23 %v2 = load i32, ptr %p2
25 ; return v0 + v1 + v2;
31 define void @no_slsr_add(i32 %b, i32 %s) {
32 ; CHECK-LABEL: @no_slsr_add(
34 ; CHECK: add i32 %b, %s
35 call void @foo(i32 %1)
37 ; CHECK: %s2 = mul i32 %s, 2
39 ; CHECK: add i32 %b, %s2
40 call void @foo(i32 %2)
44 declare void @foo(i32 %a)