1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instsimplify -S | FileCheck %s
4 @zeroinit = constant {} zeroinitializer
5 @poison = constant {} poison
6 @constzeroarray = internal constant [4 x i32] zeroinitializer
8 define i32 @crash_on_zeroinit() {
9 ; CHECK-LABEL: @crash_on_zeroinit(
10 ; CHECK-NEXT: ret i32 poison
12 %load = load i32, ptr @zeroinit
16 define i32 @crash_on_poison() {
17 ; CHECK-LABEL: @crash_on_poison(
18 ; CHECK-NEXT: ret i32 poison
20 %load = load i32, ptr @poison
24 @GV = private constant [8 x i32] [i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 48, i32 49]
26 define <8 x i32> @partial_load() {
27 ; CHECK-LABEL: @partial_load(
28 ; CHECK-NEXT: ret <8 x i32> <i32 0, i32 42, i32 43, i32 44, i32 45, i32 46, i32 47, i32 48>
30 %load = load <8 x i32>, ptr getelementptr ([8 x i32], ptr @GV, i64 0, i64 -1)
34 @constvec = internal constant <3 x float> <float 0xBFDA20BC40000000, float 0xBFE6A09EE0000000, float 0x3FE279A760000000>
36 ; This does an out of bounds load from the global constant
37 define <3 x float> @load_vec3() {
38 ; CHECK-LABEL: @load_vec3(
39 ; CHECK-NEXT: ret <3 x float> poison
41 %1 = load <3 x float>, ptr getelementptr inbounds (<3 x float>, ptr @constvec, i64 1)
45 define i32 @load_gep_const_zero_array(i64 %idx) {
46 ; CHECK-LABEL: @load_gep_const_zero_array(
47 ; CHECK-NEXT: ret i32 0
49 %gep = getelementptr inbounds [4 x i32], ptr @constzeroarray, i64 0, i64 %idx
50 %load = load i32, ptr %gep
54 define i8 @load_i8_multi_gep_const_zero_array(i64 %idx1, i64 %idx2) {
55 ; CHECK-LABEL: @load_i8_multi_gep_const_zero_array(
56 ; CHECK-NEXT: ret i8 0
58 %gep1 = getelementptr inbounds i8, ptr @constzeroarray, i64 %idx1
59 %gep = getelementptr inbounds i8, ptr %gep1, i64 %idx2
60 %load = load i8, ptr %gep