blob: a81e314bad863c1e31edfeb5ef014b9e9e0a66d3 [file] [log] [blame]
Matt Arsenault009faed2013-09-11 05:09:42 +00001; RUN: opt < %s -loop-reduce -S | FileCheck %s
2
3; LSR shouldn't consider %t8 to be an interesting user of %t6, and it
4; should be able to form pretty GEPs.
5
6target datalayout = "e-p:64:64:64-p1:16:16:16-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
7
8; Copy of uglygep with a different address space
9; This tests expandAddToGEP uses the right smaller integer type for
10; another address space
11define void @Z4() nounwind {
12; CHECK: define void @Z4
13bb:
14 br label %bb3
15
16bb1: ; preds = %bb3
17 br i1 undef, label %bb10, label %bb2
18
19bb2: ; preds = %bb1
20 %t = add i16 %t4, 1 ; <i16> [#uses=1]
21 br label %bb3
22
23bb3: ; preds = %bb2, %bb
24 %t4 = phi i16 [ %t, %bb2 ], [ 0, %bb ] ; <i16> [#uses=3]
25 br label %bb1
26
27; CHECK: bb10:
28; CHECK-NEXT: %t7 = icmp eq i16 %t4, 0
29; Host %t2 computation outside the loop.
David Blaikie79e6c742015-02-27 19:29:02 +000030; CHECK-NEXT: [[SCEVGEP:%[^ ]+]] = getelementptr i8, i8 addrspace(1)* undef, i16 %t4
Matt Arsenault009faed2013-09-11 05:09:42 +000031; CHECK-NEXT: br label %bb14
32bb10: ; preds = %bb9
33 %t7 = icmp eq i16 %t4, 0 ; <i1> [#uses=1]
34 %t3 = add i16 %t4, 16 ; <i16> [#uses=1]
35 br label %bb14
36
37; CHECK: bb14:
38; CHECK-NEXT: store i8 undef, i8 addrspace(1)* [[SCEVGEP]]
David Blaikiea79ac142015-02-27 21:17:42 +000039; CHECK-NEXT: %t6 = load float addrspace(1)*, float addrspace(1)* addrspace(1)* undef
Matt Arsenault009faed2013-09-11 05:09:42 +000040; Fold %t3's add within the address.
David Blaikie79e6c742015-02-27 19:29:02 +000041; CHECK-NEXT: [[SCEVGEP1:%[^ ]+]] = getelementptr float, float addrspace(1)* %t6, i16 4
Matt Arsenault009faed2013-09-11 05:09:42 +000042; CHECK-NEXT: [[SCEVGEP2:%[^ ]+]] = bitcast float addrspace(1)* [[SCEVGEP1]] to i8 addrspace(1)*
43; Use the induction variable (%t4) to access the right element
David Blaikie79e6c742015-02-27 19:29:02 +000044; CHECK-NEXT: [[ADDRESS:%[^ ]+]] = getelementptr i8, i8 addrspace(1)* [[SCEVGEP2]], i16 %t4
Matt Arsenault009faed2013-09-11 05:09:42 +000045; CHECK-NEXT: store i8 undef, i8 addrspace(1)* [[ADDRESS]]
46; CHECK-NEXT: br label %bb14
47bb14: ; preds = %bb14, %bb10
David Blaikie79e6c742015-02-27 19:29:02 +000048 %t2 = getelementptr inbounds i8, i8 addrspace(1)* undef, i16 %t4 ; <i8*> [#uses=1]
Matt Arsenault009faed2013-09-11 05:09:42 +000049 store i8 undef, i8 addrspace(1)* %t2
David Blaikiea79ac142015-02-27 21:17:42 +000050 %t6 = load float addrspace(1)*, float addrspace(1)* addrspace(1)* undef
Matt Arsenault009faed2013-09-11 05:09:42 +000051 %t8 = bitcast float addrspace(1)* %t6 to i8 addrspace(1)* ; <i8*> [#uses=1]
David Blaikie79e6c742015-02-27 19:29:02 +000052 %t9 = getelementptr inbounds i8, i8 addrspace(1)* %t8, i16 %t3 ; <i8*> [#uses=1]
Matt Arsenault009faed2013-09-11 05:09:42 +000053 store i8 undef, i8 addrspace(1)* %t9
54 br label %bb14
55}
56