[Bug 14664] InstCombine missing canonicalization of sub-and into a select.

Muhammad Tauqir Ahmad muhammad.t.ahmad at intel.com
Tue Jan 29 11:48:39 PST 2013


Hi,

I missed the vector case. Updated the code to handle that. Updated
another test that broke.

Please find the updated attached patch.

P.s. My patch got buried under a tonne of other posts to llvm-commits
which is why I posted on bugzilla again.

Thanks for the feedback.

- Muhammad Tauqir


On Tue, Jan 29, 2013 at 12:46 PM, Nadav Rotem <nrotem at apple.com> wrote:
> Hi Muhammad,
>
> Please send patches to llvm-commit.
>
> +  {
> +    Value *X = 0;
> +    bool OpsSwapped = false;
> +    // Canonicalize SExt or Not to the LHS
> +    if (match(Op1, m_SExt(m_Value())) ||
> +        match(Op1, m_Not(m_Value()))) {
> +      std::swap(Op0, Op1);
> +      OpsSwapped = true;
> +    }
> +
> +    // Fold (and (sext bool to A), B) --> (select bool, B, 0)
> +    if (match(Op0, m_SExt(m_Value(X))) &&
> +        X->getType()->isIntegerTy(1)) {
>
> Please make sure that this transformation also works with vector select.
>
> +      Value *zero = Constant::getNullValue(Op1->getType());
>
> zero -> Zero.
>
> +      return SelectInst::Create(X, Op1, zero);
> +    }
> +
> +    // Fold (and ~(sext bool to A), B) --> (select bool, 0, B)
> +    if (match(Op0, m_Not(m_SExt(m_Value(X)))) &&
> +        X->getType()->isIntegerTy(1)) {
> +      Value *zero = Constant::getNullValue(Op0->getType());
> +      return SelectInst::Create(X, zero, Op1);
>
> Same as above.
>
> +    }
> +
> +    if (OpsSwapped)
> +      std::swap(Op0, Op1);
> +  }
> +
>
> Thanks,
> Nadav
>
>
> On Jan 29, 2013, at 8:16 AM, bugzilla-daemon at llvm.org wrote:
>
> http://llvm.org/bugs/show_bug.cgi?id=14664
>
> --- Comment #2 from Muhammad Tauqir <muhammad.t.ahmad at intel.com> 2013-01-29
> 10:16:39 CST ---
> Submitted a patch for the "second part" of the transform:
> sext-and --> select AND sext-not-and --> select.
>
> http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20130121/163154.html
>
> Could someone please have a look?
>
> --
> Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
> ------- You are receiving this mail because: -------
> You reported the bug.
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-instcombine-missing-canonicalization-of-sext-and-to-select.patch
Type: application/octet-stream
Size: 4774 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130129/db05d8fb/attachment.obj>


More information about the llvm-commits mailing list