@@ -60,28 +60,26 @@ define i32 @load_i32_with_folded_gep_offset_nuw(ptr %p) {
6060 ret i32 %t
6161}
6262
63- @global_data = hidden local_unnamed_addr global [ 12 x i8 ] c "Hello world \00 " , align 1
64-
65- define hidden signext i8 @global_load_i32_with_folded_gep_offset_nonconst_nuw (i32 noundef %idx ) local_unnamed_addr {
66- ; CHECK-LABEL: global_load_i32_with_folded_gep_offset_nonconst_nuw :
67- ; CHECK: .functype global_load_i32_with_folded_gep_offset_nonconst_nuw (i32) -> (i32)
68- ; CHECK: i32.load8_s $push0 =, global_data($0)
69- ; CHECK: return $pop0
70- entry:
71- %arrayidx = getelementptr inbounds nuw [ 12 x i8 ] , ptr @global_data , i32 0 , i32 %idx
72- %0 = load i8 , ptr %arrayidx , align 1
73- ret i8 %0
63+ @global_data = external global i32
64+
65+ define i32 @load_i32_global_with_folded_gep_offset_nonconst_nuw (i32 %idx ) {
66+ ; CHECK-LABEL: load_i32_global_with_folded_gep_offset_nonconst_nuw :
67+ ; CHECK: i32.const $push0=, 2
68+ ; CHECK-NEXT : i32.shl $push1 =, $0, $pop0
69+ ; CHECK-NOT : i32.add
70+ ; CHECK-NEXT: i32.load $push2=, global_data($pop1)
71+ %s = getelementptr nuw i32 , ptr @global_data , i32 %idx
72+ %t = load i32 , ptr %s
73+ ret i32 %t
7474}
7575
76- define hidden signext i8 @global_load_i32_with_folded_gep_offset_const_nuw () local_unnamed_addr {
77- ; CHECK-LABEL: global_load_i32_with_folded_gep_offset_const_nuw:
78- ; CHECK: .functype global_load_i32_with_folded_gep_offset_const_nuw () -> (i32)
79- ; CHECK: i32.const $push0=, 0
80- ; CHECK: i32.load8_s $push1=, global_data+2($pop0)
81- ; CHECK: return $pop1
76+ define i32 @load_i32_global_with_folded_gep_offset_const_nuw () {
77+ ; CHECK-LABEL: load_i32_global_with_folded_gep_offset_const_nuw:
78+ ; CHECK: i32.const $push0=, 8
79+ ; CHECK-NEXT: i32.load $push1=, global_data($pop0)
8280entry:
83- %0 = load i8 , ptr getelementptr inbounds nuw (i8 , ptr @global_data , i32 2 ), align 1
84- ret i8 %0
81+ %t = load i32 , ptr getelementptr nuw (i32 , ptr @global_data , i32 2 )
82+ ret i32 %t
8583}
8684
8785
0 commit comments