[PATCH] D24565: [InstCombine] PR30366 : Teach the udiv folding logic how to handle constant expressions.
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 14 10:28:28 PDT 2016
majnemer added inline comments.
================
Comment at: lib/Transforms/InstCombine/InstCombineMulDivRem.cpp:1002
@@ +1001,3 @@
+ Value *N;
+ match(ShiftLeft, m_Shl(m_APInt(CI), m_Value(N)));
+ if (*CI != 1)
----------------
andreadb wrote:
> majnemer wrote:
> > You should check if match fails.
> In theory, this check should never fail because visitUDivOperand (see lines 1036:1040) always checks that Op1 is a left shift of a power_of_2 before adding 'foldUDivShl' to the set of folding actions.
>
> Would it be okay if I add an assertion failure if the call to match returns false?
Yes, something like:
if (!match(...))
llvm_unreachable("match shouldn't fail here!");
================
Comment at: lib/Transforms/InstCombine/InstCombineMulDivRem.cpp:1004-1005
@@ +1003,4 @@
+ if (*CI != 1)
+ N = IC.Builder->CreateAdd(N, ConstantInt::get(N->getType(),
+ CI->logBase2()));
+ if (Op1 != ShiftLeft)
----------------
This looks strangely formatted.
https://reviews.llvm.org/D24565
More information about the llvm-commits
mailing list