1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=sroa -S -o - < %s | FileCheck %s
6 declare i8* @llvm.launder.invariant.group.p0i8(i8* %a)
7 declare i8* @llvm.strip.invariant.group.p0i8(i8* %a)
8 declare void @h(i32 %a)
9 declare i32 @somevalue()
13 ; CHECK-NEXT: [[SV1:%.*]] = call i32 @somevalue()
14 ; CHECK-NEXT: [[SV2:%.*]] = call i32 @somevalue()
15 ; CHECK-NEXT: call void @h(i32 [[SV1]])
16 ; CHECK-NEXT: call void @h(i32 [[SV2]])
17 ; CHECK-NEXT: ret void
21 %a1 = getelementptr inbounds %t, %t* %a, i32 0, i32 0
22 %a1_i8 = bitcast i32* %a1 to i8*
23 %a1_i8_inv = call i8* @llvm.launder.invariant.group.p0i8(i8* %a1_i8)
24 %a1_inv = bitcast i8* %a1_i8_inv to i32*
25 %a2 = getelementptr inbounds %t, %t* %a, i32 0, i32 1
27 %sv1 = call i32 @somevalue()
28 %sv2 = call i32 @somevalue()
30 store i32 %sv1, i32* %a1_inv, !invariant.group !0
31 store i32 %sv2, i32* %a2
33 %v1 = load i32, i32* %a1_inv, !invariant.group !0
34 %v2 = load i32, i32* %a2
44 ; CHECK-NEXT: [[A:%.*]] = alloca [[T:%.*]], align 8
45 ; CHECK-NEXT: [[A1:%.*]] = getelementptr inbounds [[T]], %t* [[A]], i32 0, i32 0
46 ; CHECK-NEXT: [[A1_I8:%.*]] = bitcast i32* [[A1]] to i8*
47 ; CHECK-NEXT: [[A1_I8_INV:%.*]] = call i8* @llvm.launder.invariant.group.p0i8(i8* [[A1_I8]])
48 ; CHECK-NEXT: [[A1_INV:%.*]] = bitcast i8* [[A1_I8_INV]] to i32*
49 ; CHECK-NEXT: [[A2:%.*]] = getelementptr inbounds [[T]], %t* [[A]], i32 0, i32 1
50 ; CHECK-NEXT: [[SV1:%.*]] = call i32 @somevalue()
51 ; CHECK-NEXT: [[SV2:%.*]] = call i32 @somevalue()
52 ; CHECK-NEXT: store i32 [[SV1]], i32* [[A1_INV]], align 4, !invariant.group !0
53 ; CHECK-NEXT: store i32 [[SV2]], i32* [[A2]], align 4
54 ; CHECK-NEXT: [[V1:%.*]] = load i32, i32* [[A1_INV]], align 4, !invariant.group !0
55 ; CHECK-NEXT: [[V2:%.*]] = load i32, i32* [[A2]], align 4
56 ; CHECK-NEXT: call void @h(i32 [[V1]])
57 ; CHECK-NEXT: call void @h(i32 [[V2]])
58 ; CHECK-NEXT: [[A1_STRIPPED:%.*]] = call i8* @llvm.strip.invariant.group.p0i8(i8* [[A1_I8]])
59 ; CHECK-NEXT: [[A1_INT:%.*]] = ptrtoint i8* [[A1_STRIPPED]] to i32
60 ; CHECK-NEXT: call void @h(i32 [[A1_INT]])
61 ; CHECK-NEXT: ret void
65 %a1 = getelementptr inbounds %t, %t* %a, i32 0, i32 0
66 %a1_i8 = bitcast i32* %a1 to i8*
67 %a1_i8_inv = call i8* @llvm.launder.invariant.group.p0i8(i8* %a1_i8)
68 %a1_inv = bitcast i8* %a1_i8_inv to i32*
69 %a2 = getelementptr inbounds %t, %t* %a, i32 0, i32 1
71 %sv1 = call i32 @somevalue()
72 %sv2 = call i32 @somevalue()
74 store i32 %sv1, i32* %a1_inv, !invariant.group !0
75 store i32 %sv2, i32* %a2
77 %v1 = load i32, i32* %a1_inv, !invariant.group !0
78 %v2 = load i32, i32* %a2
83 %a1_stripped = call i8* @llvm.strip.invariant.group.p0i8(i8* %a1_i8)
84 %a1_int = ptrtoint i8* %a1_stripped to i32
85 call void @h(i32 %a1_int)