[PATCH] InstCombine Check if Signed Addition Overflows
Rafael EspĂndola
rafael.espindola at gmail.com
Tue May 27 06:59:47 PDT 2014
Sorry for the delay, I was stuck in the GlobalAlias patches.
Please be sure to address Jingyue Wu comment too.
+ APInt LHSKnownZero(BitWidth, 0, 1);
Since the value is 0, there is no difference in passing isSigned=true.
If you think that is better to be explicit, please write it as
APInt LHSKnownZero(BitWidth, 0, /*isSigned*/ true);
+ // TODO: Handle for Vectors.
The comment is more for the entire function, no just this particular
case. Please move it to the top.
+ if (RHSKnownOne.countPopulation() == 1)
Jingyue Wu comment....
Please don't duplicate the code to handle the symmetry. You can
probably use a small static helper function and write
if (helper(LHSKnowZero, LHSKnowOne, RHSKnownZero, RHSKnownOne))
return true;
if (helper(RHSKnownZero, RHSKnownOne, LHSKnowZero, LHSKnowOne))
return true;
+ int LHSZeroPosition = BitWidth - LHSKnownZero.countLeadingZeros() - 1;
Please add a FIXME about this missing the case where LHS has a zero
before the 1 in the RHS, but also has one after.
Cheers,
Rafael
More information about the llvm-commits
mailing list