[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

Bill Wendling isanbard at gmail.com
Mon Dec 1 11:30:26 PST 2008


On Mon, Dec 1, 2008 at 8:48 AM, Chris Lattner <clattner at apple.com> wrote:
> 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?
>
I was looking at the logic last night and couldn't see anything
obviously wrong with doing the simple pointer test. I'll go ahead and
make the changes.

-bw



More information about the llvm-commits mailing list