negate_cc_compare_p = true;
}
- diff = (unsigned HOST_WIDE_INT) ct - (unsigned HOST_WIDE_INT) cf;
+ diff = (unsigned HOST_WIDE_INT) ct - cf;
+ /* Make sure we can represent the difference between the two values. */
+ if ((diff > 0) != ((cf < 0) != (ct < 0) ? cf < 0 : cf < ct))
+ return false;
+
/* Sign bit compares are better done using shifts than we do by using
sbb. */
if (sign_bit_compare_p
reverse_condition (GET_CODE (compare_op)));
}
- diff = (unsigned HOST_WIDE_INT) ct - (unsigned HOST_WIDE_INT) cf;
+ diff = (unsigned HOST_WIDE_INT) ct - cf;
+ /* Make sure we can represent the difference
+ between the two values. */
+ if ((diff > 0) != ((cf < 0) != (ct < 0) ? cf < 0 : cf < ct))
+ return false;
if (reg_overlap_mentioned_p (out, compare_op))
tmp = gen_reg_rtx (mode);
else
{
std::swap (ct, cf);
- diff = (unsigned HOST_WIDE_INT) ct
- - (unsigned HOST_WIDE_INT) cf;
+
+ diff = (unsigned HOST_WIDE_INT) ct - cf;
+ /* Make sure we can represent the difference
+ between the two values. */
+ if ((diff > 0) != ((cf < 0) != (ct < 0) ? cf < 0 : cf < ct))
+ return false;
}
tmp = emit_store_flag (tmp, code, op0, op1, VOIDmode, 0, -1);
}
tmp = expand_simple_unop (mode, NOT, tmp, copy_rtx (tmp), 1);
}
- HOST_WIDE_INT ival = (unsigned HOST_WIDE_INT) cf
- - (unsigned HOST_WIDE_INT) ct;
+ HOST_WIDE_INT ival = (unsigned HOST_WIDE_INT) cf - ct;
+ /* Make sure we can represent the difference
+ between the two values. */
+ if ((ival > 0) != ((ct < 0) != (cf < 0) ? ct < 0 : ct < cf))
+ return false;
+
tmp = expand_simple_binop (mode, AND,
copy_rtx (tmp),
gen_int_mode (ival, mode),
if (new_code != UNKNOWN)
{
std::swap (ct, cf);
- diff = (unsigned HOST_WIDE_INT) ct - (unsigned HOST_WIDE_INT) cf;
+
+ diff = (unsigned HOST_WIDE_INT) ct - cf;
+ /* Make sure we can represent the difference
+ between the two values. */
+ if ((diff > 0) != ((cf < 0) != (ct < 0) ? cf < 0 : cf < ct))
+ return false;
+
code = new_code;
}
}
copy_rtx (out), 1, OPTAB_DIRECT);
}
- HOST_WIDE_INT ival = (unsigned HOST_WIDE_INT) cf
- - (unsigned HOST_WIDE_INT) ct;
+ HOST_WIDE_INT ival = (unsigned HOST_WIDE_INT) cf - ct;
+ /* Make sure we can represent the difference
+ between the two values. */
+ if ((ival > 0) != ((ct < 0) != (cf < 0) ? ct < 0 : ct < cf))
+ return false;
+
out = expand_simple_binop (mode, AND, copy_rtx (out),
gen_int_mode (ival, mode),
copy_rtx (out), 1, OPTAB_DIRECT);