[llvm-commits] [llvm] r60275 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/apint-sub.ll test/Transforms/InstCombine/sdiv-1.ll test/Transforms/InstCombine/sub.ll
Chris Lattner
clattner at apple.com
Mon Dec 1 08:48:37 PST 2008
On Nov 30, 2008, at 11:59 PM, Bill Wendling wrote:
>>> + // -X/C -> X/-C, if and only if negation doesn't overflow.
>>> + if ((RHS->getSExtValue() < 0 &&
>>> + RHS->getSExtValue() < RHSNeg->getSExtValue()) ||
>>> + (RHS->getSExtValue() > 0 &&
>>> + RHS->getSExtValue() > RHSNeg->getSExtValue())) {
>>
>> How about checking: "RHSNext != RHS" ?
>>
> I've since changed this. It's now:
>
> if ((RHS->getValue().isNegative() &&
> RHSNegAPI.slt(TwoToExp - 1)) ||
> (RHS->getValue().isNonNegative() &&
> RHSNegAPI.sgt(TwoToExp * NegOne))) {
>
> This is what Hacker's Delight gave me (for -1*y). I can change it to
> RHSNeg != RHS if you think that this will always hold in this case
> (the non-negative part seems to be not necessary). What do you think?
I'd strongly prefer that you replace all that logic with a simple
pointer test, if it is safe. Is it safe?
-Chris
More information about the llvm-commits
mailing list