diff options
Diffstat (limited to 'gcc/cfgexpand.c')
-rw-r--r-- | gcc/cfgexpand.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index 1d3f96f..b73019b 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -2621,6 +2621,14 @@ expand_gimple_cond (basic_block bb, gcond *stmt) && TREE_CODE (op1) == INTEGER_CST) code = maybe_optimize_mod_cmp (code, &op0, &op1); + /* Optimize (x - y) < 0 into x < y if x - y has undefined overflow. */ + if (!TYPE_UNSIGNED (TREE_TYPE (op0)) + && (code == LT_EXPR || code == LE_EXPR + || code == GT_EXPR || code == GE_EXPR) + && integer_zerop (op1) + && TREE_CODE (op0) == SSA_NAME) + maybe_optimize_sub_cmp_0 (code, &op0, &op1); + last2 = last = get_last_insn (); extract_true_false_edges_from_block (bb, &true_edge, &false_edge); |