[TwoAddressInstructionPass] When looking for a 3 addr conversion after commuting...
[oota-llvm.git] / test / CodeGen / X86 / lsr-redundant-addressing.ll
1 ; RUN: llc -march=x86-64 < %s | FileCheck %s
2 ; rdar://9081094
3
4 ; LSR shouldn't create lots of redundant address computations.
5
6 %0 = type { i32, [3 x i32] }
7 %1 = type { i32 (i32, i32, i32)*, i32, i32, [3 x i32], i8*, i8*, i8* }
8
9 @pgm = external hidden unnamed_addr global [5 x %0], align 32
10 @isa = external hidden unnamed_addr constant [13 x %1], align 32
11
12 define void @main_bb.i() nounwind {
13 ; CHECK: main_bb.i:
14 ; CHECK-NOT: ret
15 ; CHECK: addq $-16,
16 ; CHECK-NOT: ret
17 ; CHECK: ret
18
19 bb:
20   br label %bb38
21
22 bb38:                                             ; preds = %bb200, %bb
23   %tmp39 = phi i64 [ %tmp201, %bb200 ], [ 0, %bb ]
24   %tmp40 = sub i64 0, %tmp39
25   %tmp47 = getelementptr [5 x %0], [5 x %0]* @pgm, i64 0, i64 %tmp40, i32 0
26   %tmp34 = load i32, i32* %tmp47, align 16
27   %tmp203 = icmp slt i32 %tmp34, 12
28   br i1 %tmp203, label %bb215, label %bb200
29
30 bb200:                                            ; preds = %bb38
31   %tmp201 = add i64 %tmp39, 1
32   br label %bb38
33
34 bb215:                                            ; preds = %bb38
35   %tmp50 = getelementptr [5 x %0], [5 x %0]* @pgm, i64 0, i64 %tmp40, i32 1, i64 2
36   %tmp49 = getelementptr [5 x %0], [5 x %0]* @pgm, i64 0, i64 %tmp40, i32 1, i64 1
37   %tmp48 = getelementptr [5 x %0], [5 x %0]* @pgm, i64 0, i64 %tmp40, i32 1, i64 0
38   %tmp216 = add nsw i32 %tmp34, 1
39   store i32 %tmp216, i32* %tmp47, align 16
40   %tmp217 = sext i32 %tmp216 to i64
41   %tmp218 = getelementptr inbounds [13 x %1], [13 x %1]* @isa, i64 0, i64 %tmp217, i32 3, i64 0
42   %tmp219 = load i32, i32* %tmp218, align 8
43   store i32 %tmp219, i32* %tmp48, align 4
44   %tmp220 = getelementptr inbounds [13 x %1], [13 x %1]* @isa, i64 0, i64 %tmp217, i32 3, i64 1
45   %tmp221 = load i32, i32* %tmp220, align 4
46   store i32 %tmp221, i32* %tmp49, align 4
47   %tmp222 = getelementptr inbounds [13 x %1], [13 x %1]* @isa, i64 0, i64 %tmp217, i32 3, i64 2
48   %tmp223 = load i32, i32* %tmp222, align 8
49   store i32 %tmp223, i32* %tmp50, align 4
50   ret void
51 }