[llvm-commits] [llvm] r157032 - in /llvm/trunk: lib/Support/ConstantRange.cpp unittests/Support/ConstantRangeTest.cpp

Nuno Lopes nunoplopes at sapo.pt
Fri May 18 10:47:10 PDT 2012


done: r157058.
Nuno

Citando Owen Anderson <resistor at mac.com>:

> Test case?
>
> On May 17, 2012, at 5:14 PM, Nuno Lopes <nunoplopes at sapo.pt> wrote:
>
>> Author: nlopes
>> Date: Thu May 17 19:14:36 2012
>> New Revision: 157032
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=157032&view=rev
>> Log:
>> fix corner case in ConstantRange::intersectWith().
>> this fixes the missed optimization I was seeing in the  
>> CorrelatedValuePropagation pass
>>
>> Modified:
>>    llvm/trunk/lib/Support/ConstantRange.cpp
>>    llvm/trunk/unittests/Support/ConstantRangeTest.cpp
>>
>> Modified: llvm/trunk/lib/Support/ConstantRange.cpp
>> URL:  
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/ConstantRange.cpp?rev=157032&r1=157031&r2=157032&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/Support/ConstantRange.cpp (original)
>> +++ llvm/trunk/lib/Support/ConstantRange.cpp Thu May 17 19:14:36 2012
>> @@ -288,7 +288,7 @@
>>       if (CR.Upper.ult(Upper))
>>         return CR;
>>
>> -      if (CR.Upper.ult(Lower))
>> +      if (CR.Upper.ule(Lower))
>>         return ConstantRange(CR.Lower, Upper);
>>
>>       if (getSetSize().ult(CR.getSetSize()))
>>
>> Modified: llvm/trunk/unittests/Support/ConstantRangeTest.cpp
>> URL:  
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/ConstantRangeTest.cpp?rev=157032&r1=157031&r2=157032&view=diff
>> ==============================================================================
>> --- llvm/trunk/unittests/Support/ConstantRangeTest.cpp (original)
>> +++ llvm/trunk/unittests/Support/ConstantRangeTest.cpp Thu May 17  
>> 19:14:36 2012
>> @@ -232,6 +232,11 @@
>>   ConstantRange LHS(APInt(16, 4), APInt(16, 2));
>>   ConstantRange RHS(APInt(16, 6), APInt(16, 5));
>>   EXPECT_TRUE(LHS.intersectWith(RHS) == LHS);
>> +
>> +  // previous bug: intersection of [min, 3) and [2, max) should be 2
>> +  LHS = ConstantRange(APInt(32, -2147483648), APInt(32, 3));
>> +  RHS = ConstantRange(APInt(32, 2), APInt(32, 2147483648));
>> +  EXPECT_EQ(LHS.intersectWith(RHS), ConstantRange(APInt(32, 2)));
>> }
>>
>> TEST_F(ConstantRangeTest, UnionWith) {
>>



More information about the llvm-commits mailing list