[9] RFR(S): 8043284: Optimize signed integer comparison

Tobias Hartmann tobias.hartmann at oracle.com
Mon Aug 4 14:45:37 UTC 2014

Hi Rickard,

thanks for the review.

> could we add the logic to a new method and make a method call instead?

Sure, but if we want to reuse the local variables from 'BoolNode::Ideal' 
(for example, 'cmp2_type') as Vladimir suggested, we would have a 
signature similar to this:

Node* BoolNode::my_optimization(PhaseGVN* phase, Node* cmp, Node* cmp1, 
Node* cmp2, int cmp_op, int cmp1_op, const TypeInt* cmp2_type) {

An alternative would be to only pass (PhaseGVN* phase, Node* cmp) and 
re-compute the other variables.

What do you prefer?


> Thanks
> /R
> On 07/31, Tobias Hartmann wrote:
>> Hi,
>> please review the following patch that fixes JDK-8043284.
>> Bug: https://bugs.openjdk.java.net/browse/JDK-8043284
>> Webrev: http://cr.openjdk.java.net/~thartmann/8043284/webrev.00/
>> == Problem ==
>> Similar to the previous implementation of unsigned integer
>> comparison (see JDK- 8042786), signed integer comparison does only
>> consider the general integer range [MinInt, MaxInt] instead of two
>> ranges when comparing the result of an overflowing AddI/SubI.
>> However, there are situations where one can prove that both
>> resulting ranges are unequal to the tested value (see
>> 'TestIntegerComparison::testSigned' in the webrev). In this case the
>> comparison can be optimized.
>> == Solution ==
>> Similar to the fix for JDK-8042786 we compute both type ranges if
>> the add/sub overflows and compare them to the tested value. If we
>> can prove that the value is always unequal, we replace the BoolNode
>> by true or false (depending on the test).
>> A jtreg test is added that triggers both the unsigned as well as the
>> signed optimization.
>> == Testing ==
>> - Jtreg test (TestIntegerComparison)
>> - JPRT
>> Thanks,
>> Tobias

More information about the hotspot-compiler-dev mailing list