[PATCH] D51236: [InstCombine] Extend (add (sext x), cst) --> (sext (add x, cst')) and (add (zext x), cst) --> (zext (add x, cst')) to work for vectors

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 25 10:14:11 PDT 2018


craig.topper added inline comments.


================
Comment at: lib/Transforms/InstCombine/InstCombineAddSub.cpp:1199
+    Constant *RHSC;
+    if (match(RHS, m_ConstantIntOrConstantIntVec(RHSC))) {
       if (LHSConv->hasOneUse()) {
----------------
spatel wrote:
> I don't understand what benefit the new pattern matcher offers. We're already guaranteed that the constant is (vector) integer type because this is an 'add'. Do we need to disallow constant expressions? If not, use the existing m_Constant() matcher?
I did it to disallow constant expressions and be better than just using m_APInt. I don't think willNotOverflowSignedAdd will give an answer for constant expressions in general. So we'd just be creating new constant expressions with the call get to ConstantExpr::getTrunc for no reason. And we'd need tests for it.


https://reviews.llvm.org/D51236





More information about the llvm-commits mailing list