[llvm] [WebAssembly] Fold unsigned offset (PR #145829)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 1 11:11:14 PDT 2025
================
@@ -60,6 +60,31 @@ define i32 @load_i32_with_folded_gep_offset_nuw(ptr %p) {
ret i32 %t
}
+ at global_data = hidden local_unnamed_addr global [12 x i8] c"Hello world\00", align 1
+
+define hidden signext i8 @global_load_i32_with_folded_gep_offset_nonconst_nuw(i32 noundef %idx) local_unnamed_addr {
+; CHECK-LABEL: global_load_i32_with_folded_gep_offset_nonconst_nuw:
+; CHECK: .functype global_load_i32_with_folded_gep_offset_nonconst_nuw (i32) -> (i32)
+; CHECK: i32.load8_s $push0=, global_data($0)
+; CHECK: return $pop0
+entry:
+ %arrayidx = getelementptr inbounds nuw [12 x i8], ptr @global_data, i32 0, i32 %idx
+ %0 = load i8, ptr %arrayidx, align 1
+ ret i8 %0
----------------
lukel97 wrote:
Try to keep it to an i32 load to match the other tests
```suggestion
%s = getelementptr nuw i32, ptr @global_data, i32 %idx
%t = load i32, ptr %s
ret i8 %t
```
https://github.com/llvm/llvm-project/pull/145829
More information about the llvm-commits
mailing list