[PATCH] D155718: [InstCombine] Remove unneeded isa<PHINode> check in foldOpIntoPhi

Dhruv Chawla via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 19 10:23:29 PDT 2023


0xdc03 updated this revision to Diff 542099.
0xdc03 added a comment.

- Add test case


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D155718/new/

https://reviews.llvm.org/D155718

Files:
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/test/Transforms/InstCombine/icmp-fold-into-phi.ll


Index: llvm/test/Transforms/InstCombine/icmp-fold-into-phi.ll
===================================================================
--- llvm/test/Transforms/InstCombine/icmp-fold-into-phi.ll
+++ llvm/test/Transforms/InstCombine/icmp-fold-into-phi.ll
@@ -32,18 +32,14 @@
 ; CHECK:       cond.end:
 ; CHECK-NEXT:    [[TMP4:%.*]] = load ptr, ptr @ObjVal, align 8
 ; CHECK-NEXT:    [[CALL4:%.*]] = tail call zeroext i1 @StrCmp(ptr noundef [[TMP4]], ptr noundef nonnull @.str.3)
-; CHECK-NEXT:    [[COND:%.*]] = select i1 [[CALL4]], i32 127, i32 126
 ; CHECK-NEXT:    br label [[SW_BB]]
 ; CHECK:       sw.bb:
-; CHECK-NEXT:    [[COND2:%.*]] = phi i32 [ [[COND]], [[COND_END]] ], [ 128, [[COND_FALSE3]] ]
 ; CHECK-NEXT:    [[CALL5:%.*]] = tail call zeroext i1 @CheckCond()
 ; CHECK-NEXT:    [[NOT_CALL5:%.*]] = xor i1 [[CALL5]], true
 ; CHECK-NEXT:    br label [[SW_EPILOG]]
 ; CHECK:       sw.epilog:
-; CHECK-NEXT:    [[COND3:%.*]] = phi i32 [ [[COND2]], [[SW_BB]] ], [ 134, [[COND_FALSE2]] ], [ 2, [[COND_FALSE]] ], [ 1, [[ENTRY:%.*]] ]
-; CHECK-NEXT:    [[TAGERROR_0:%.*]] = phi i1 [ [[NOT_CALL5]], [[SW_BB]] ], [ false, [[COND_FALSE2]] ], [ false, [[COND_FALSE]] ], [ false, [[ENTRY]] ]
-; CHECK-NEXT:    [[CMP:%.*]] = icmp ult i32 [[COND3]], 2
-; CHECK-NEXT:    [[BRMERGE:%.*]] = or i1 [[CMP]], [[TAGERROR_0]]
+; CHECK-NEXT:    [[TAGERROR_0:%.*]] = phi i1 [ [[NOT_CALL5]], [[SW_BB]] ], [ false, [[COND_FALSE2]] ], [ false, [[COND_FALSE]] ], [ false, [[ENTRY:%.*]] ]
+; CHECK-NEXT:    [[BRMERGE:%.*]] = or i1 [[CALL]], [[TAGERROR_0]]
 ; CHECK-NEXT:    [[RETVAL2_VAL:%.*]] = load i32, ptr @RetVal2, align 4
 ; CHECK-NEXT:    [[RETVAL1_VAL:%.*]] = load i32, ptr @RetVal1, align 4
 ; CHECK-NEXT:    [[RETVAL_0:%.*]] = select i1 [[BRMERGE]], i32 [[RETVAL2_VAL]], i32 [[RETVAL1_VAL]]
Index: llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -1297,7 +1297,6 @@
       continue;
     }
 
-    if (isa<PHINode>(InVal)) return nullptr;  // Itself a phi.
     if (NonSimplifiedBB) return nullptr;  // More than one non-simplified value.
 
     NonSimplifiedBB = InBB;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155718.542099.patch
Type: text/x-patch
Size: 2256 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230719/84a16da5/attachment.bin>


More information about the llvm-commits mailing list