Skip to content

Commit

Permalink
[CGP] Drop poison-generating flags in optimizeBranch
Browse files Browse the repository at this point in the history
  • Loading branch information
dtcxzyw committed Apr 28, 2024
1 parent 1c8e4bb commit 7e7bf0b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions llvm/lib/CodeGen/CodeGenPrepare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8270,6 +8270,7 @@ static bool optimizeBranch(BranchInst *Branch, const TargetLowering &TLI,
IRBuilder<> Builder(Branch);
if (UI->getParent() != Branch->getParent())
UI->moveBefore(Branch);
UI->dropPoisonGeneratingFlags();
Value *NewCmp = Builder.CreateCmp(ICmpInst::ICMP_EQ, UI,
ConstantInt::get(UI->getType(), 0));
LLVM_DEBUG(dbgs() << "Converting " << *Cmp << "\n");
Expand All @@ -8283,6 +8284,7 @@ static bool optimizeBranch(BranchInst *Branch, const TargetLowering &TLI,
IRBuilder<> Builder(Branch);
if (UI->getParent() != Branch->getParent())
UI->moveBefore(Branch);
UI->dropPoisonGeneratingFlags();
Value *NewCmp = Builder.CreateCmp(Cmp->getPredicate(), UI,
ConstantInt::get(UI->getType(), 0));
LLVM_DEBUG(dbgs() << "Converting " << *Cmp << "\n");
Expand Down
6 changes: 3 additions & 3 deletions llvm/test/Transforms/CodeGenPrepare/RISCV/convert-to-eqz.ll
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ define i8 @hoist_add(i8 %x) {
; CHECK-LABEL: define i8 @hoist_add(
; CHECK-SAME: i8 [[X:%.*]]) {
; CHECK-NEXT: entry:
; CHECK-NEXT: [[INC:%.*]] = add nuw nsw i8 [[X]], 1
; CHECK-NEXT: [[INC:%.*]] = add i8 [[X]], 1
; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i8 [[INC]], 0
; CHECK-NEXT: br i1 [[TMP0]], label [[EXIT:%.*]], label [[IF_THEN:%.*]]
; CHECK: if.then:
Expand All @@ -31,7 +31,7 @@ define i8 @hoist_lshr(i8 %x) {
; CHECK-LABEL: define i8 @hoist_lshr(
; CHECK-SAME: i8 [[X:%.*]]) {
; CHECK-NEXT: entry:
; CHECK-NEXT: [[INC:%.*]] = lshr exact i8 [[X]], 3
; CHECK-NEXT: [[INC:%.*]] = lshr i8 [[X]], 3
; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i8 [[INC]], 0
; CHECK-NEXT: br i1 [[TMP0]], label [[EXIT:%.*]], label [[IF_THEN:%.*]]
; CHECK: if.then:
Expand All @@ -57,7 +57,7 @@ define i8 @nomove_add(i8 %x) {
; CHECK-LABEL: define i8 @nomove_add(
; CHECK-SAME: i8 [[X:%.*]]) {
; CHECK-NEXT: entry:
; CHECK-NEXT: [[INC:%.*]] = add nuw nsw i8 [[X]], 1
; CHECK-NEXT: [[INC:%.*]] = add i8 [[X]], 1
; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i8 [[INC]], 0
; CHECK-NEXT: br i1 [[TMP0]], label [[EXIT:%.*]], label [[IF_THEN:%.*]]
; CHECK: if.then:
Expand Down

0 comments on commit 7e7bf0b

Please sign in to comment.