fix formatting; NFC

llvm-svn: 280727
This commit is contained in:
Sanjay Patel 2016-09-06 18:16:31 +00:00
parent 5715012b9e
commit 4e463b4a2c
1 changed files with 14 additions and 19 deletions

View File

@ -1133,29 +1133,24 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) {
if (Instruction *IV = FoldSelectOpOp(SI, TI, FI)) if (Instruction *IV = FoldSelectOpOp(SI, TI, FI))
return IV; return IV;
// (select C, (sext X), const) -> (sext (select C, X, const')) and // (select C, (ext X), const) -> (ext (select C, X, const')) and variations
// variations thereof when extending from i1, as that allows further folding // thereof when extending from i1, as that allows further folding into logic
// into logic ops. When the sext is from a larger type, we prefer to have it // ops. When the sext is from a larger type, prefer to have it as an operand.
// as an operand. if (TI && (TI->getOpcode() == Instruction::ZExt ||
if (TI && TI->getOpcode() == Instruction::SExt)) {
(TI->getOpcode() == Instruction::ZExt || TI->getOpcode() == Instruction::SExt)) {
bool IsSExt = TI->getOpcode() == Instruction::SExt; bool IsSExt = TI->getOpcode() == Instruction::SExt;
const APInt *C; const APInt *C;
if (match(FalseVal, m_APInt(C))) { if (match(FalseVal, m_APInt(C)))
if (Instruction *IV = if (auto *I = foldSelectExtConst(*Builder, SI, TI, *C, true, IsSExt))
foldSelectExtConst(*Builder, SI, TI, *C, true, IsSExt)) return I;
return IV;
}
} }
if (FI && if (FI && (FI->getOpcode() == Instruction::ZExt ||
(FI->getOpcode() == Instruction::ZExt || FI->getOpcode() == Instruction::SExt)) { FI->getOpcode() == Instruction::SExt)) {
bool IsSExt = FI->getOpcode() == Instruction::SExt; bool IsSExt = FI->getOpcode() == Instruction::SExt;
const APInt *C; const APInt *C;
if (match(TrueVal, m_APInt(C))) { if (match(TrueVal, m_APInt(C)))
if (Instruction *IV = if (auto *I = foldSelectExtConst(*Builder, SI, FI, *C, false, IsSExt))
foldSelectExtConst(*Builder, SI, FI, *C, false, IsSExt)) return I;
return IV;
}
} }
// See if we can fold the select into one of our operands. // See if we can fold the select into one of our operands.
@ -1293,7 +1288,7 @@ Instruction *InstCombiner::visitSelectInst(SelectInst &SI) {
return &SI; return &SI;
} }
if (VectorType* VecTy = dyn_cast<VectorType>(SelType)) { if (VectorType *VecTy = dyn_cast<VectorType>(SelType)) {
unsigned VWidth = VecTy->getNumElements(); unsigned VWidth = VecTy->getNumElements();
APInt UndefElts(VWidth, 0); APInt UndefElts(VWidth, 0);
APInt AllOnesEltMask(APInt::getAllOnesValue(VWidth)); APInt AllOnesEltMask(APInt::getAllOnesValue(VWidth));