< prev index next >

src/share/vm/opto/loopTransform.cpp

Print this page
rev 9644 : 8145096: Undefined behaviour in HotSpot
Summary: Fix some integer overflows
Reviewed-by: duke

@@ -1397,12 +1397,12 @@
           assert(has_ctrl(opaq), "should have it");
           Node* opaq_ctrl = get_ctrl(opaq);
           limit = new Opaque2Node( C, limit );
           register_new_node( limit, opaq_ctrl );
         }
-        if (stride_con > 0 && ((limit_type->_lo - stride_con) < limit_type->_lo) ||
-                   stride_con < 0 && ((limit_type->_hi - stride_con) > limit_type->_hi)) {
+        if (stride_con > 0 && (java_subtract(limit_type->_lo, stride_con) < limit_type->_lo) ||
+            stride_con < 0 && (java_subtract(limit_type->_hi, stride_con) > limit_type->_hi)) {
           // No underflow.
           new_limit = new SubINode(limit, stride);
         } else {
           // (limit - stride) may underflow.
           // Clamp the adjustment value with MININT or MAXINT:
< prev index next >