diff options
Diffstat (limited to 'gcc/tree-ssa-math-opts.cc')
-rw-r--r-- | gcc/tree-ssa-math-opts.cc | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/gcc/tree-ssa-math-opts.cc b/gcc/tree-ssa-math-opts.cc index eb03ebe..7e819f3 100644 --- a/gcc/tree-ssa-math-opts.cc +++ b/gcc/tree-ssa-math-opts.cc @@ -4104,15 +4104,34 @@ build_saturation_binary_arith_call_and_insert (gimple_stmt_iterator *gsi, * _10 = -_9; * _12 = _7 | _10; * => - * _12 = .SAT_ADD (_4, _6); */ + * _12 = .SAT_ADD (_4, _6); + * + * Try to match IMM=-1 saturation signed add with assign. + * <bb 2> [local count: 1073741824]: + * x.0_1 = (unsigned char) x_5(D); + * _3 = -x.0_1; + * _10 = (signed char) _3; + * _8 = x_5(D) & _10; + * if (_8 < 0) + * goto <bb 4>; [1.40%] + * else + * goto <bb 3>; [98.60%] + * <bb 3> [local count: 434070867]: + * _2 = x.0_1 + 255; + * <bb 4> [local count: 1073741824]: + * # _9 = PHI <_2(3), 128(2)> + * _4 = (int8_t) _9; + * => + * _4 = .SAT_ADD (x_5, -1); */ static void -match_unsigned_saturation_add (gimple_stmt_iterator *gsi, gassign *stmt) +match_saturation_add_with_assign (gimple_stmt_iterator *gsi, gassign *stmt) { tree ops[2]; tree lhs = gimple_assign_lhs (stmt); - if (gimple_unsigned_integer_sat_add (lhs, ops, NULL)) + if (gimple_unsigned_integer_sat_add (lhs, ops, NULL) + || gimple_signed_integer_sat_add (lhs, ops, NULL)) build_saturation_binary_arith_call_and_replace (gsi, IFN_SAT_ADD, lhs, ops[0], ops[1]); } @@ -6403,7 +6422,7 @@ math_opts_dom_walker::after_dom_children (basic_block bb) break; case PLUS_EXPR: - match_unsigned_saturation_add (&gsi, as_a<gassign *> (stmt)); + match_saturation_add_with_assign (&gsi, as_a<gassign *> (stmt)); match_unsigned_saturation_sub (&gsi, as_a<gassign *> (stmt)); /* fall-through */ case MINUS_EXPR: @@ -6429,7 +6448,7 @@ math_opts_dom_walker::after_dom_children (basic_block bb) break; case BIT_IOR_EXPR: - match_unsigned_saturation_add (&gsi, as_a<gassign *> (stmt)); + match_saturation_add_with_assign (&gsi, as_a<gassign *> (stmt)); match_unsigned_saturation_trunc (&gsi, as_a<gassign *> (stmt)); /* fall-through */ case BIT_XOR_EXPR: @@ -6450,6 +6469,7 @@ math_opts_dom_walker::after_dom_children (basic_block bb) case NOP_EXPR: match_unsigned_saturation_trunc (&gsi, as_a<gassign *> (stmt)); + match_saturation_add_with_assign (&gsi, as_a<gassign *> (stmt)); break; default:; |