[llvm] [InstCombine] Increase recursion limit to 3 in `simplifyNonNullOperand` (PR #128695)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 25 05:20:08 PST 2025
================
@@ -451,3 +451,33 @@ define i32 @load_select_with_null_gep(i1 %cond, ptr %p, i64 %off) {
%res = load i32, ptr %gep, align 4
ret i32 %res
}
+
+define i16 @load_select_with_null_gep2(i1 %cond, ptr %p, i64 %x) {
+; CHECK-LABEL: @load_select_with_null_gep2(
+; CHECK-NEXT: [[INVARIANT_GEP:%.*]] = getelementptr i8, ptr [[SEL:%.*]], i64 -2
+; CHECK-NEXT: [[GEP:%.*]] = getelementptr i16, ptr [[INVARIANT_GEP]], i64 [[X:%.*]]
+; CHECK-NEXT: [[RES:%.*]] = load i16, ptr [[GEP]], align 2
+; CHECK-NEXT: ret i16 [[RES]]
+;
+ %sel = select i1 %cond, ptr %p, ptr null
+ %invariant.gep = getelementptr i8, ptr %sel, i64 -2
+ %gep = getelementptr i16, ptr %invariant.gep, i64 %x
+ %res = load i16, ptr %gep, align 2
+ ret i16 %res
+}
+
+define i16 @load_select_with_null_ge3(i1 %cond, ptr %p, i64 %x, i64 %y) {
----------------
nikic wrote:
```suggestion
define i16 @load_select_with_null_gep3(i1 %cond, ptr %p, i64 %x, i64 %y) {
```
https://github.com/llvm/llvm-project/pull/128695
More information about the llvm-commits
mailing list