Pattern match integer [SU]MIN, [SU]MAX and ABS idioms, returning the kind and providing the out parameter results if we successfully match.
Declared in <llvm/Analysis/ValueTracking.h>
SelectPatternResult
matchSelectPattern(
Value* V,
Value*& LHS,
Value*& RHS,
Instruction::CastOps* CastOp = nullptr,
unsigned int Depth = 0);
For ABS/NABS, LHS will be set to the input to the abs idiom. RHS will be the negation instruction from the idiom.
If CastOp is not nullptr, also match MIN/MAX idioms where the type does not match that of the original select. If this is the case, the cast operation (one of Trunc,SExt,Zext) that must be done to transform the type of LHS and RHS into the type of V is returned in CastOp.
For example: %1 = icmp slt i32 %a, i32 4 %2 = sext i32 %a to i64 %3 = select i1 %1, i64 %2, i64 4
-> LHS = %a, RHS = i32 4, *CastOp = Instruction::SExt
Matched select pattern result.
| Name | Description |
|---|---|
| V | Select (or equivalent) value to match. |
| LHS | Output left-hand operand of the matched idiom. |
| RHS | Output right-hand operand of the matched idiom. |
| CastOp | Optional output cast needed to unify operand types. |
| Depth | Current recursion depth for this query. |