Skip to content
This repository has been archived by the owner on Jan 1, 2023. It is now read-only.

Commit

Permalink
fix formatting; NFC
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282737 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
rotateright committed Sep 29, 2016
1 parent b19d280 commit 61724e6
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions lib/Transforms/InstCombine/InstCombineSelect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -920,28 +920,26 @@ static Instruction *foldAddSubSelect(SelectInst &SI,
/// we may be able to create an i1 select which can be further folded to
/// logical ops.
static Instruction *foldSelectExtConst(InstCombiner::BuilderTy &Builder,
SelectInst &SI, Instruction *EI,
const APInt &C, bool isExtTrueVal,
bool isSigned) {
Value *SmallVal = EI->getOperand(0);
SelectInst &SI, Instruction *ExtInst,
const APInt &C, bool IsExtTrueVal,
bool IsSigned) {
Value *SmallVal = ExtInst->getOperand(0);
Type *SmallType = SmallVal->getType();

// TODO Handle larger types as well? Note this requires adjusting
// FoldOpIntoSelect as well.
// TODO: Handle larger types? That requires adjusting FoldOpIntoSelect too.
if (!SmallType->getScalarType()->isIntegerTy(1))
return nullptr;

if (C != 0 && (isSigned || C != 1) &&
(!isSigned || !C.isAllOnesValue()))
if (C != 0 && (IsSigned || C != 1) && (!IsSigned || !C.isAllOnesValue()))
return nullptr;

Value *SmallConst = ConstantInt::get(SmallType, C.trunc(1));
Value *TrueVal = isExtTrueVal ? SmallVal : SmallConst;
Value *FalseVal = isExtTrueVal ? SmallConst : SmallVal;
Value *TrueVal = IsExtTrueVal ? SmallVal : SmallConst;
Value *FalseVal = IsExtTrueVal ? SmallConst : SmallVal;
Value *Select = Builder.CreateSelect(SI.getOperand(0), TrueVal, FalseVal,
"fold." + SI.getName(), &SI);

if (isSigned)
if (IsSigned)
return new SExtInst(Select, SI.getType());

return new ZExtInst(Select, SI.getType());
Expand Down

0 comments on commit 61724e6

Please sign in to comment.