Skip to content

Commit 3853aee

Browse files
committed
[InstCombine] Increase recursion limit to 3 in simplifyNonNullOperand
1 parent 72781f5 commit 3853aee

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,8 @@ Value *InstCombinerImpl::simplifyNonNullOperand(Value *V,
996996
if (!V->hasOneUse())
997997
return nullptr;
998998

999-
if (Depth == 1)
999+
constexpr unsigned RecursionLimit = 3;
1000+
if (Depth == RecursionLimit)
10001001
return nullptr;
10011002

10021003
if (auto *GEP = dyn_cast<GetElementPtrInst>(V)) {

llvm/test/Transforms/InstCombine/load.ll

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,7 @@ define i32 @load_select_with_null_gep(i1 %cond, ptr %p, i64 %off) {
454454

455455
define i16 @load_select_with_null_gep2(i1 %cond, ptr %p, i64 %x) {
456456
; CHECK-LABEL: @load_select_with_null_gep2(
457-
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], ptr [[P:%.*]], ptr null
458-
; CHECK-NEXT: [[INVARIANT_GEP:%.*]] = getelementptr i8, ptr [[SEL]], i64 -2
457+
; CHECK-NEXT: [[INVARIANT_GEP:%.*]] = getelementptr i8, ptr [[SEL:%.*]], i64 -2
459458
; CHECK-NEXT: [[GEP:%.*]] = getelementptr i16, ptr [[INVARIANT_GEP]], i64 [[X:%.*]]
460459
; CHECK-NEXT: [[RES:%.*]] = load i16, ptr [[GEP]], align 2
461460
; CHECK-NEXT: ret i16 [[RES]]
@@ -469,8 +468,7 @@ define i16 @load_select_with_null_gep2(i1 %cond, ptr %p, i64 %x) {
469468

470469
define i16 @load_select_with_null_ge3(i1 %cond, ptr %p, i64 %x, i64 %y) {
471470
; CHECK-LABEL: @load_select_with_null_ge3(
472-
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], ptr [[P:%.*]], ptr null
473-
; CHECK-NEXT: [[INVARIANT_GEP:%.*]] = getelementptr i8, ptr [[SEL]], i64 -2
471+
; CHECK-NEXT: [[INVARIANT_GEP:%.*]] = getelementptr i8, ptr [[SEL:%.*]], i64 -2
474472
; CHECK-NEXT: [[GEP:%.*]] = getelementptr i16, ptr [[INVARIANT_GEP]], i64 [[X:%.*]]
475473
; CHECK-NEXT: [[GEP2:%.*]] = getelementptr i16, ptr [[GEP]], i64 [[Y:%.*]]
476474
; CHECK-NEXT: [[RES:%.*]] = load i16, ptr [[GEP2]], align 2

0 commit comments

Comments
 (0)