19 return match(U, m_Intrinsic<Intrinsic::experimental_guard>());
23 return match(V, m_Intrinsic<Intrinsic::experimental_widenable_condition>());
27 Value *Condition, *WidenableCondition;
36 BasicBlock *DeoptBB = cast<BranchInst>(U)->getSuccessor(1);
40 for (
auto &
Insn : *DeoptBB) {
41 if (
match(&
Insn, m_Intrinsic<Intrinsic::experimental_deoptimize>()))
43 if (
Insn.mayHaveSideEffects())
46 DeoptBB = DeoptBB->getUniqueSuccessor();
49 }
while (Visited.
insert(DeoptBB).second);
54 Value *&WidenableCondition,
63 WidenableCondition = WC->get();
72 auto *BI = dyn_cast<BranchInst>(U);
73 if (!BI || !BI->isConditional())
75 auto *
Cond = BI->getCondition();
76 if (!
Cond->hasOneUse())
79 IfTrueBB = BI->getSuccessor(0);
80 IfFalseBB = BI->getSuccessor(1);
82 if (
match(
Cond, m_Intrinsic<Intrinsic::experimental_widenable_condition>())) {
83 WC = &BI->getOperandUse(0);
96 auto *
And = dyn_cast<Instruction>(
Cond);
101 if (
match(
A, m_Intrinsic<Intrinsic::experimental_widenable_condition>()) &&
103 WC = &
And->getOperandUse(0);
104 C = &
And->getOperandUse(1);
108 if (
match(
B, m_Intrinsic<Intrinsic::experimental_widenable_condition>()) &&
110 WC = &
And->getOperandUse(1);
111 C = &
And->getOperandUse(0);
117template <
typename CallbackType>
119 CallbackType RecordCheckOrWidenableCond) {
122 Visited.
insert(Condition);
133 if (!RecordCheckOrWidenableCond(
Check))
135 }
while (!Worklist.
empty());
141 Value *Condition =
isGuard(U) ? cast<IntrinsicInst>(U)->getArgOperand(0)
142 : cast<BranchInst>(U)->getCondition();
152 auto *BI = dyn_cast<BranchInst>(U);
153 if (!BI || !BI->isConditional())
156 auto Condition = BI->getCondition();
157 if (!Condition->hasOneUse())
160 Value *WidenableCondition =
nullptr;
165 WidenableCondition = Check;
170 return WidenableCondition;
SmallVector< AArch64_IMM::ImmInsnModel, 4 > Insn
static void parseCondition(Value *Condition, CallbackType RecordCheckOrWidenableCond)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
const SmallVectorImpl< MachineOperand > & Cond
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Basic Block Representation.
LLVMContext & getContext() const
Get the context in which this basic block lives.
static ConstantInt * getTrue(LLVMContext &Context)
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
A Use represents the edge between a Value definition and its users.
LLVM Value Representation.
@ C
The default llvm calling convention, compatible with C.
BinaryOp_match< LHS, RHS, Instruction::And > m_And(const LHS &L, const RHS &R)
bool match(Val *V, const Pattern &P)
class_match< Value > m_Value()
Match an arbitrary value and ignore it.
This is an optimization pass for GlobalISel generic memory operations.
Value * extractWidenableCondition(const User *U)
void parseWidenableGuard(const User *U, llvm::SmallVectorImpl< Value * > &Checks)
bool isGuard(const User *U)
Returns true iff U has semantics of a guard expressed in a form of call of llvm.experimental....
bool isWidenableCondition(const Value *V)
Returns true iff V has semantics of llvm.experimental.widenable.condition call.
bool parseWidenableBranch(const User *U, Value *&Condition, Value *&WidenableCondition, BasicBlock *&IfTrueBB, BasicBlock *&IfFalseBB)
If U is widenable branch looking like: cond = ... wc = call i1 @llvm.experimental....
bool isWidenableBranch(const User *U)
Returns true iff U is a widenable branch (that is, extractWidenableCondition returns widenable condit...
bool isGuardAsWidenableBranch(const User *U)
Returns true iff U has semantics of a guard expressed in a form of a widenable conditional branch to ...
@ And
Bitwise or logical AND of integers.