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 ptr @llvm.strip.invariant.group.p0(ptr %p)
8 declare ptr @llvm.launder.invariant.group.p0(ptr %p)
12 ; CHECK-NEXT: ret i64 3
14 %a = call ptr @llvm.strip.invariant.group.p0(ptr @A)
15 %b = getelementptr i8, ptr %a, i32 8
22 ; CHECK-NEXT: ret i64 3
24 %a = call ptr @llvm.launder.invariant.group.p0(ptr @A)
25 %b = getelementptr i8, ptr %a, i32 8
30 define i64 @notconstantglobal() {
31 ; CHECK-LABEL: @notconstantglobal(
32 ; CHECK-NEXT: [[A:%.*]] = call ptr @llvm.launder.invariant.group.p0(ptr @B)
33 ; CHECK-NEXT: [[B:%.*]] = getelementptr i8, ptr [[A]], i32 8
34 ; CHECK-NEXT: [[D:%.*]] = load i64, ptr [[B]], align 4
35 ; CHECK-NEXT: ret i64 [[D]]
37 %a = call ptr @llvm.launder.invariant.group.p0(ptr @B)
38 %b = getelementptr i8, ptr %a, i32 8
43 define i64 @notconstantgepindex(i32 %i) {
44 ; CHECK-LABEL: @notconstantgepindex(
45 ; CHECK-NEXT: [[A:%.*]] = call ptr @llvm.launder.invariant.group.p0(ptr @A)
46 ; CHECK-NEXT: [[B:%.*]] = getelementptr i8, ptr [[A]], i32 [[I:%.*]]
47 ; CHECK-NEXT: [[D:%.*]] = load i64, ptr [[B]], align 4
48 ; CHECK-NEXT: ret i64 [[D]]
50 %a = call ptr @llvm.launder.invariant.group.p0(ptr @A)
51 %b = getelementptr i8, ptr %a, i32 %i
56 define i64 @volatile() {
57 ; CHECK-LABEL: @volatile(
58 ; CHECK-NEXT: [[A:%.*]] = call ptr @llvm.launder.invariant.group.p0(ptr @A)
59 ; CHECK-NEXT: [[B:%.*]] = getelementptr i8, ptr [[A]], i32 8
60 ; CHECK-NEXT: [[D:%.*]] = load volatile i64, ptr [[B]], align 4
61 ; CHECK-NEXT: ret i64 [[D]]
63 %a = call ptr @llvm.launder.invariant.group.p0(ptr @A)
64 %b = getelementptr i8, ptr %a, i32 8
65 %d = load volatile i64, ptr %b