Skip to content

Commit

Permalink
[InstCombine] Remove unneeded isa<PHINode> check in foldOpIntoPhi
Browse files Browse the repository at this point in the history
This check is redundant as it is covered by the call to
isPotentiallyReachable.

Depends on D155726.

Differential Revision: https://reviews.llvm.org/D155718
  • Loading branch information
dc03 committed Aug 16, 2023
1 parent e549d57 commit d53b3df
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
1 change: 0 additions & 1 deletion llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1396,7 +1396,6 @@ Instruction *InstCombinerImpl::foldOpIntoPhi(Instruction &I, PHINode *PN) {
continue;
}

if (isa<PHINode>(InVal)) return nullptr; // Itself a phi.
if (NonSimplifiedBB) return nullptr; // More than one non-simplified value.

NonSimplifiedBB = InBB;
Expand Down
7 changes: 3 additions & 4 deletions llvm/test/Analysis/ValueTracking/known-power-of-two-urem.ll
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ define i64 @known_power_of_two_urem_phi(i64 %size, i1 %cmp, i1 %cmp1) {
; 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:
Expand Down
8 changes: 4 additions & 4 deletions llvm/test/Transforms/InstCombine/icmp-fold-into-phi.ll
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ define i1 @SwitchTest(i32 %x, i32 %y) {
; 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 [
Expand Down

0 comments on commit d53b3df

Please sign in to comment.