Commit 644e7476 authored by Juneyoung Lee's avatar Juneyoung Lee Committed by aqjune
Browse files

[ValueTracking] Let getGuaranteedNonFullPoisonOp consider assume, remove mentioning about br

Summary:
This patch helps getGuaranteedNonFullPoisonOp handle llvm.assume call.
Also, a comment about the semantics of branch is removed to prevent confusion.
As llvm.assume does, branching on poison directly raises UB (as LangRef says), and this allows transformations such as introduction of llvm.assume on branch condition at each successor, or freely replacing values after conditional branch (such as at loop exit).
Handling br is not addressed in this patch. It makes SCEV more accurate, causing existing LoopVectorize/IndVar/etc tests to fail.

Reviewers: spatel, lebedev.ri, nlopes

Reviewed By: nlopes

Subscribers: hiraditya, javed.absar, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D75397
parent 282ec405
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -4708,11 +4708,18 @@ const Value *llvm::getGuaranteedNonFullPoisonOp(const Instruction *I) {
    case Instruction::SRem:
      return I->getOperand(1);

    case Instruction::Call:
      if (auto *II = dyn_cast<IntrinsicInst>(I)) {
        switch (II->getIntrinsicID()) {
        case Intrinsic::assume:
          return II->getArgOperand(0);
        default:
          return nullptr;
        }
      }
      return nullptr;

    default:
      // Note: It's really tempting to think that a conditional branch or
      // switch should be listed here, but that's incorrect.  It's not
      // branching off of poison which is UB, it is executing a side effecting
      // instruction which follows the branch.
      return nullptr;
  }
}