|
LLVM
4.0.0
|
#include "InstCombineInternal.h"#include "llvm/Analysis/ConstantFolding.h"#include "llvm/Analysis/InstructionSimplify.h"#include "llvm/Analysis/ValueTracking.h"#include "llvm/IR/MDBuilder.h"#include "llvm/IR/PatternMatch.h"Go to the source code of this file.
Macros | |
| #define | DEBUG_TYPE "instcombine" |
Functions | |
| static SelectPatternFlavor | getInverseMinMaxSelectPattern (SelectPatternFlavor SPF) |
| static CmpInst::Predicate | getCmpPredicateForMinMax (SelectPatternFlavor SPF, bool Ordered=false) |
| static Value * | generateMinMaxSelectPattern (InstCombiner::BuilderTy *Builder, SelectPatternFlavor SPF, Value *A, Value *B) |
| static unsigned | getSelectFoldableOperands (Instruction *I) |
| We want to turn code that looks like this: C = or A, B D = select cond, C, A into: C = select cond, B, 0 D = or A, C. More... | |
| static Constant * | getSelectFoldableConstant (Instruction *I) |
| For the same transformation as the previous function, return the identity constant that goes into the select. More... | |
| static bool | isSelect01 (Constant *C1, Constant *C2) |
| static Value * | foldSelectICmpAndOr (const SelectInst &SI, Value *TrueVal, Value *FalseVal, InstCombiner::BuilderTy *Builder) |
| We want to turn: (select (icmp eq (and X, C1), 0), Y, (or Y, C2)) into: (or (shl (and X, C1), C3), y) iff: C1 and C2 are both powers of 2 where: C3 = Log(C2) - Log(C1) More... | |
| #define DEBUG_TYPE "instcombine" |
Definition at line 23 of file InstCombineSelect.cpp.
|
static |
We want to turn: (select (icmp eq (and X, C1), 0), Y, (or Y, C2)) into: (or (shl (and X, C1), C3), y) iff: C1 and C2 are both powers of 2 where: C3 = Log(C2) - Log(C1)
This transform handles cases where:
Definition at line 305 of file InstCombineSelect.cpp.
References llvm::IRBuilder< T, Inserter >::CreateLShr(), llvm::IRBuilder< T, Inserter >::CreateOr(), llvm::IRBuilder< T, Inserter >::CreateShl(), llvm::IRBuilder< T, Inserter >::CreateXor(), llvm::IRBuilder< T, Inserter >::CreateZExtOrTrunc(), llvm::dyn_cast(), llvm::SelectInst::getCondition(), llvm::User::getOperand(), llvm::CmpInst::getPredicate(), llvm::Value::getType(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::ICmpInst::isEquality(), llvm::Type::isIntegerTy(), llvm::APInt::logBase2(), llvm::PatternMatch::m_And(), llvm::PatternMatch::m_Or(), llvm::PatternMatch::m_Power2(), llvm::PatternMatch::m_Specific(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::m_Zero(), llvm::PatternMatch::match(), X, and Y.
|
static |
Definition at line 63 of file InstCombineSelect.cpp.
References A, assert(), B, llvm::IRBuilder< T, Inserter >::CreateICmp(), llvm::IRBuilder< T, Inserter >::CreateSelect(), getCmpPredicateForMinMax(), and llvm::CmpInst::isIntPredicate().
|
static |
Definition at line 42 of file InstCombineSelect.cpp.
References llvm::CmpInst::FCMP_OGT, llvm::CmpInst::FCMP_OLT, llvm::CmpInst::FCMP_UGT, llvm::CmpInst::FCMP_ULT, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULT, llvm_unreachable, llvm::SPF_FMAXNUM, llvm::SPF_FMINNUM, llvm::SPF_SMAX, llvm::SPF_SMIN, llvm::SPF_UMAX, and llvm::SPF_UMIN.
Referenced by generateMinMaxSelectPattern().
|
static |
Definition at line 26 of file InstCombineSelect.cpp.
References llvm_unreachable, llvm::SPF_SMAX, llvm::SPF_SMIN, llvm::SPF_UMAX, and llvm::SPF_UMIN.
|
static |
For the same transformation as the previous function, return the identity constant that goes into the select.
Definition at line 102 of file InstCombineSelect.cpp.
References llvm::MCID::Add, llvm::APIntOps::And(), llvm::ConstantInt::get(), llvm::Constant::getAllOnesValue(), llvm::Constant::getNullValue(), llvm::Instruction::getOpcode(), llvm::Value::getType(), llvm_unreachable, llvm::APIntOps::Or(), and llvm::APIntOps::Xor().
|
static |
We want to turn code that looks like this: C = or A, B D = select cond, C, A into: C = select cond, B, 0 D = or A, C.
Assuming that the specified instruction is an operand to the select, return a bitmask indicating which operands of this instruction are foldable if they equal the other incoming value of the select.
Definition at line 82 of file InstCombineSelect.cpp.
References llvm::MCID::Add, llvm::APIntOps::And(), llvm::Instruction::getOpcode(), llvm::APIntOps::Or(), and llvm::APIntOps::Xor().
Definition at line 210 of file InstCombineSelect.cpp.
References llvm::dyn_cast(), llvm::Constant::isAllOnesValue(), llvm::ConstantInt::isOne(), and llvm::ConstantInt::isZero().
1.8.6