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

Dhruv Chawla via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 16 08:40:22 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rGd53b3df570e3: [InstCombine] Remove unneeded isa<PHINode> check in foldOpIntoPhi (authored by 0xdc03).

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/Analysis/ValueTracking/known-power-of-two-urem.ll
  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
@@ -10,14 +10,14 @@
 ; CHECK-NEXT:    i32 1, label [[BB3:%.*]]
 ; CHECK-NEXT:    ]
 ; CHECK:       bb1:
+; CHECK-NEXT:    [[TMP0:%.*]] = icmp ugt i32 [[Y]], 1
 ; CHECK-NEXT:    br label [[BB2]]
 ; CHECK:       bb2:
-; CHECK-NEXT:    [[PHI1:%.*]] = phi i32 [ 1, [[ENTRY:%.*]] ], [ [[Y]], [[BB1]] ]
+; CHECK-NEXT:    [[PHI1:%.*]] = phi i1 [ false, [[ENTRY:%.*]] ], [ [[TMP0]], [[BB1]] ]
 ; CHECK-NEXT:    br label [[BB3]]
 ; CHECK:       bb3:
-; CHECK-NEXT:    [[PHI2:%.*]] = phi i32 [ [[PHI1]], [[BB2]] ], [ 0, [[ENTRY]] ]
-; CHECK-NEXT:    [[CMP:%.*]] = icmp ugt i32 [[PHI2]], 1
-; CHECK-NEXT:    ret i1 [[CMP]]
+; CHECK-NEXT:    [[PHI2:%.*]] = phi i1 [ [[PHI1]], [[BB2]] ], [ false, [[ENTRY]] ]
+; CHECK-NEXT:    ret i1 [[PHI2]]
 ;
 entry:
   switch i32 %x, label %bb1 [
Index: llvm/test/Analysis/ValueTracking/known-power-of-two-urem.ll
===================================================================
--- llvm/test/Analysis/ValueTracking/known-power-of-two-urem.ll
+++ llvm/test/Analysis/ValueTracking/known-power-of-two-urem.ll
@@ -15,12 +15,11 @@
 ; CHECK:       cond.true.false:
 ; CHECK-NEXT:    br label [[COND_TRUE_END]]
 ; CHECK:       cond.true.end:
-; CHECK-NEXT:    [[PHI:%.*]] = phi i64 [ 2, [[COND_TRUE_TRUE]] ], [ 4, [[COND_TRUE_FALSE]] ]
+; CHECK-NEXT:    [[PHI:%.*]] = phi i64 [ 1, [[COND_TRUE_TRUE]] ], [ 3, [[COND_TRUE_FALSE]] ]
 ; CHECK-NEXT:    br label [[COND_END]]
 ; CHECK:       cond.end:
-; CHECK-NEXT:    [[PHI1:%.*]] = phi i64 [ 4096, [[ENTRY:%.*]] ], [ [[PHI]], [[COND_TRUE_END]] ]
-; CHECK-NEXT:    [[TMP0:%.*]] = add nsw i64 [[PHI1]], -1
-; CHECK-NEXT:    [[UREM:%.*]] = and i64 [[TMP0]], [[SIZE:%.*]]
+; CHECK-NEXT:    [[PHI1:%.*]] = phi i64 [ 4095, [[ENTRY:%.*]] ], [ [[PHI]], [[COND_TRUE_END]] ]
+; CHECK-NEXT:    [[UREM:%.*]] = and i64 [[PHI1]], [[SIZE:%.*]]
 ; CHECK-NEXT:    ret i64 [[UREM]]
 ;
 entry:
Index: llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -1396,7 +1396,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.550775.patch
Type: text/x-patch
Size: 2571 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230816/1db2d33f/attachment.bin>


More information about the llvm-commits mailing list