1 ; RUN: opt < %s -slsr -gvn -S | FileCheck %s
3 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-unknown-linux-gnu"
6 ; Do not perform SLSR on &input[s] and &input[s * 2] which fit into addressing
8 define i32 @no_slsr_gep(i32* %input, i64 %s) {
9 ; CHECK-LABEL: @no_slsr_gep(
11 %p0 = getelementptr inbounds i32, i32* %input, i64 0
12 %v0 = load i32, i32* %p0
15 %p1 = getelementptr inbounds i32, i32* %input, i64 %s
16 ; CHECK: %p1 = getelementptr inbounds i32, i32* %input, i64 %s
17 %v1 = load i32, i32* %p1
20 %s2 = mul nsw i64 %s, 2
21 %p2 = getelementptr inbounds i32, i32* %input, i64 %s2
22 ; CHECK: %p2 = getelementptr inbounds i32, i32* %input, i64 %s2
23 %v2 = load i32, i32* %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)