[PATCH] InstCombineCompare with constant return false if we know it is never going to be equal
Duncan Sands
baldrick at free.fr
Wed Jun 4 08:20:06 PDT 2014
On 04/06/14 15:28, Duncan Sands wrote:
> Hi Suyog,
>> + // If the KnownBits of LHS and RHS at same bit position differ,
>> + // LHS and RHS are not equal.
>
> I think this comment is misleading. If KnownBitsLHS != KnownBitsRHS it doesn't
> mean that LHS != RHS, but the comment seems to be saying that.
>
>> + if (ConstantInt *CI = dyn_cast<ConstantInt>(RHS)) {
>> + uint32_t BitWidth = CI->getBitWidth();
>> + APInt LHSKnownZero(BitWidth, 0, 1);
>
> Why not just: APInt LHSKnownZero(BitWidth);
PS: I have to admit that all callers of computeKnownBits initialize their APInt
to zero, eg:
APInt LHSKnownZero(BitWidth, 0);
In my opinion this should either be documented as a requirement of
computeKnownBits, or documented as not being a requirement and computeKnownBits
should zero out the APInts as the first step. Setting the APInts to be signed
is definitely pointless.
More information about the llvm-commits
mailing list