[llvm-commits] [llvm] r135471 - /llvm/trunk/test/Transforms/InstSimplify/compare.ll

Nick Lewycky nicholas at mxc.ca
Tue Jul 26 01:25:05 PDT 2011


Duncan Sands wrote:
> Hi Nick,
>
>> Remove bogus test: for all possible inputs of %X, the 'sub nsw' is guaranteed
>> to perform a signed wrap. Don't rely on any particular handling of that case.
>
> I don't understand what you are saying.  "sub nsw" never does a signed wrap (if
> it does the program performs undefined behaviour).  In the testcase, %A is
> positive while %B is negative.  Thus %C is positive because there is no signed
> wrap.  Thus %D is positive or zero and %E is false.

If you feed 'sub nsw' an input which sign-wraps, then you've encountered 
undefined behaviour. That's what I'm claiming always happens; this test 
*always* puts the sub in a situation where it needs to do a signed wrap.

%Y doesn't feed into the sub, so let's look at i16 %X. %A has 16-bits of 
0 followed by 16-bits of unknown. %B has the sign bit set, then 15 bits 
of 0, followed by the same 16-bits of unknown.

Visualized in hex with free variables pqrs, that's 0000pqrs - 7000pqrs = 
70000000. If I understand the definition of nsw correctly, we aren't 
allowed to wrap that way.

>
> Ciao, Duncan.
>
>>
>> Modified:
>>       llvm/trunk/test/Transforms/InstSimplify/compare.ll
>>
>> Modified: llvm/trunk/test/Transforms/InstSimplify/compare.ll
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstSimplify/compare.ll?rev=135471&r1=135470&r2=135471&view=diff
>> ==============================================================================
>> --- llvm/trunk/test/Transforms/InstSimplify/compare.ll (original)
>> +++ llvm/trunk/test/Transforms/InstSimplify/compare.ll Tue Jul 19 03:22:57 2011
>> @@ -283,17 +283,6 @@
>>      ret i1 %E
>>    }
>>
>> -; CHECK: @srem4
>> -; CHECK-NEXT: ret i1 false
>> -define i1 @srem4(i16 %X, i32 %Y) {
>> -  %A = zext i16 %X to i32
>> -  %B = or i32 2147483648, %A
>> -  %C = sub nsw i32 %A, %B
>> -  %D = srem i32 %C, %Y
>> -  %E = icmp slt i32 %D, 0
>> -  ret i1 %E
>> -}
>> -
>>    define i1 @udiv1(i32 %X) {
>>    ; CHECK: @udiv1
>>      %A = udiv i32 %X, 1000000
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>




More information about the llvm-commits mailing list