[llvm] r274465 - [InstCombine] enable vector select of bools -> logic folds
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 6 11:09:55 PDT 2016
On Sun, Jul 3, 2016 at 7:34 AM, Sanjay Patel via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> Author: spatel
> Date: Sun Jul 3 09:34:39 2016
> New Revision: 274465
>
> URL: http://llvm.org/viewvc/llvm-project?rev=274465&view=rev
> Log:
> [InstCombine] enable vector select of bools -> logic folds
>
> Modified:
> llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp
> llvm/trunk/test/Transforms/InstCombine/select.ll
>
> Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp?rev=274465&r1=274464&r2=274465&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp (original)
> +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineSelect.cpp Sun Jul 3
> 09:34:39 2016
> @@ -918,9 +918,11 @@ Instruction *InstCombiner::visitSelectIn
> SimplifySelectInst(CondVal, TrueVal, FalseVal, DL, TLI, DT, AC))
> return replaceInstUsesWith(SI, V);
>
> - if (SI.getType()->isIntegerTy(1)) {
> - if (ConstantInt *C = dyn_cast<ConstantInt>(TrueVal)) {
> - if (C->getZExtValue()) {
> + if (SI.getType()->getScalarType()->isIntegerTy(1) &&
> + TrueVal->getType() == CondVal->getType()) {
> + const APInt *TrueC;
> + if (match(TrueVal, m_APInt(TrueC))) {
> + if (TrueC->isAllOnesValue()) {
>
m_One()?
> // Change: A = select B, true, C --> A = or B, C
> return BinaryOperator::CreateOr(CondVal, FalseVal);
> }
> @@ -928,8 +930,9 @@ Instruction *InstCombiner::visitSelectIn
> Value *NotCond = Builder->CreateNot(CondVal, "not." +
> CondVal->getName());
> return BinaryOperator::CreateAnd(NotCond, FalseVal);
> }
> - if (ConstantInt *C = dyn_cast<ConstantInt>(FalseVal)) {
> - if (!C->getZExtValue()) {
> + const APInt *FalseC;
> + if (match(FalseVal, m_APInt(FalseC))) {
>
m_Zero()?
-Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160706/acbb125d/attachment.html>
More information about the llvm-commits
mailing list