1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=instsimplify -S < %s | FileCheck %s
4 @A = linkonce_odr hidden constant { i64, i64 } { i64 2, i64 3 }
5 @B = linkonce_odr hidden global { i64, i64 } { i64 2, i64 3 }
7 declare i8* @llvm.strip.invariant.group.p0i8(i8* %p)
8 declare i8* @llvm.launder.invariant.group.p0i8(i8* %p)
12 ; CHECK-NEXT: ret i64 3
14 %p = bitcast { i64, i64 }* @A to i8*
15 %a = call i8* @llvm.strip.invariant.group.p0i8(i8* %p)
16 %b = getelementptr i8, i8* %a, i32 8
17 %c = bitcast i8* %b to i64*
18 %d = load i64, i64* %c
24 ; CHECK-NEXT: ret i64 3
26 %p = bitcast { i64, i64 }* @A to i8*
27 %a = call i8* @llvm.launder.invariant.group.p0i8(i8* %p)
28 %b = getelementptr i8, i8* %a, i32 8
29 %c = bitcast i8* %b to i64*
30 %d = load i64, i64* %c
34 define i64 @notconstantglobal() {
35 ; CHECK-LABEL: @notconstantglobal(
36 ; CHECK-NEXT: [[A:%.*]] = call i8* @llvm.launder.invariant.group.p0i8(i8* bitcast ({ i64, i64 }* @B to i8*))
37 ; CHECK-NEXT: [[B:%.*]] = getelementptr i8, i8* [[A]], i32 8
38 ; CHECK-NEXT: [[C:%.*]] = bitcast i8* [[B]] to i64*
39 ; CHECK-NEXT: [[D:%.*]] = load i64, i64* [[C]], align 4
40 ; CHECK-NEXT: ret i64 [[D]]
42 %p = bitcast { i64, i64 }* @B to i8*
43 %a = call i8* @llvm.launder.invariant.group.p0i8(i8* %p)
44 %b = getelementptr i8, i8* %a, i32 8
45 %c = bitcast i8* %b to i64*
46 %d = load i64, i64* %c
50 define i64 @notconstantgepindex(i32 %i) {
51 ; CHECK-LABEL: @notconstantgepindex(
52 ; CHECK-NEXT: [[A:%.*]] = call i8* @llvm.launder.invariant.group.p0i8(i8* bitcast ({ i64, i64 }* @A to i8*))
53 ; CHECK-NEXT: [[B:%.*]] = getelementptr i8, i8* [[A]], i32 [[I:%.*]]
54 ; CHECK-NEXT: [[C:%.*]] = bitcast i8* [[B]] to i64*
55 ; CHECK-NEXT: [[D:%.*]] = load i64, i64* [[C]], align 4
56 ; CHECK-NEXT: ret i64 [[D]]
58 %p = bitcast { i64, i64 }* @A to i8*
59 %a = call i8* @llvm.launder.invariant.group.p0i8(i8* %p)
60 %b = getelementptr i8, i8* %a, i32 %i
61 %c = bitcast i8* %b to i64*
62 %d = load i64, i64* %c
66 define i64 @volatile() {
67 ; CHECK-LABEL: @volatile(
68 ; CHECK-NEXT: [[A:%.*]] = call i8* @llvm.launder.invariant.group.p0i8(i8* bitcast ({ i64, i64 }* @A to i8*))
69 ; CHECK-NEXT: [[B:%.*]] = getelementptr i8, i8* [[A]], i32 8
70 ; CHECK-NEXT: [[C:%.*]] = bitcast i8* [[B]] to i64*
71 ; CHECK-NEXT: [[D:%.*]] = load volatile i64, i64* [[C]], align 4
72 ; CHECK-NEXT: ret i64 [[D]]
74 %p = bitcast { i64, i64 }* @A to i8*
75 %a = call i8* @llvm.launder.invariant.group.p0i8(i8* %p)
76 %b = getelementptr i8, i8* %a, i32 8
77 %c = bitcast i8* %b to i64*
78 %d = load volatile i64, i64* %c