diff options
author | Sanjay Patel <spatel@rotateright.com> | 2016-06-08 20:31:52 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2016-06-08 20:31:52 +0000 |
commit | 384d0f219d92b327a3a38ca613257dbf5e0911f1 (patch) | |
tree | b0d704acccc31eb6fb9c64d1cb54c9640fffcc2a /llvm/lib/Transforms | |
parent | 3e2f389a7e4d277c4d2787129b0f7479459a7772 (diff) | |
download | bcm5719-llvm-384d0f219d92b327a3a38ca613257dbf5e0911f1.tar.gz bcm5719-llvm-384d0f219d92b327a3a38ca613257dbf5e0911f1.zip |
[InstCombine] fix outdated comment, simplify logic; NFCI
llvm-svn: 272196
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp index 9a3a2e43272..a76d4118abb 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp @@ -120,22 +120,19 @@ static Constant *GetSelectFoldableConstant(Instruction *I) { /// have the same opcode and only one use each. Try to simplify this. Instruction *InstCombiner::FoldSelectOpOp(SelectInst &SI, Instruction *TI, Instruction *FI) { - if (TI->getNumOperands() == 1) { - // If this is a non-volatile load or a cast from the same type, - // merge. - if (TI->isCast()) { - Type *FIOpndTy = FI->getOperand(0)->getType(); - if (TI->getOperand(0)->getType() != FIOpndTy) - return nullptr; - // The select condition may be a vector. We may only change the operand - // type if the vector width remains the same (and matches the condition). - Type *CondTy = SI.getCondition()->getType(); - if (CondTy->isVectorTy() && (!FIOpndTy->isVectorTy() || - CondTy->getVectorNumElements() != FIOpndTy->getVectorNumElements())) - return nullptr; - } else { - return nullptr; // unknown unary op. - } + // If this is a cast from the same type, merge. + if (TI->getNumOperands() == 1 && TI->isCast()) { + Type *FIOpndTy = FI->getOperand(0)->getType(); + if (TI->getOperand(0)->getType() != FIOpndTy) + return nullptr; + + // The select condition may be a vector. We may only change the operand + // type if the vector width remains the same (and matches the condition). + Type *CondTy = SI.getCondition()->getType(); + if (CondTy->isVectorTy() && + (!FIOpndTy->isVectorTy() || + CondTy->getVectorNumElements() != FIOpndTy->getVectorNumElements())) + return nullptr; // Fold this by inserting a select from the input values. Value *NewSI = Builder->CreateSelect(SI.getCondition(), TI->getOperand(0), |