+2019-05-22 Richard Biener <rguenther@suse.de>
+
+ * gimple-fold.c (arith_code_with_undefined_signed_overflow):
+ Add ABS_EXPR.
+ (rewrite_to_defined_overflow): Handle rewriting ABS_EXPR
+ as ABSU_EXPR.
+
2019-05-22 Alan Modra <amodra@gmail.com>
* config/rs6000/rs6000.h (ASM_OPT_ANY): Define.
{
switch (code)
{
+ case ABS_EXPR:
case PLUS_EXPR:
case MINUS_EXPR:
case MULT_EXPR:
tree lhs = gimple_assign_lhs (stmt);
tree type = unsigned_type_for (TREE_TYPE (lhs));
gimple_seq stmts = NULL;
- for (unsigned i = 1; i < gimple_num_ops (stmt); ++i)
- {
- tree op = gimple_op (stmt, i);
- op = gimple_convert (&stmts, type, op);
- gimple_set_op (stmt, i, op);
- }
+ if (gimple_assign_rhs_code (stmt) == ABS_EXPR)
+ gimple_assign_set_rhs_code (stmt, ABSU_EXPR);
+ else
+ for (unsigned i = 1; i < gimple_num_ops (stmt); ++i)
+ {
+ tree op = gimple_op (stmt, i);
+ op = gimple_convert (&stmts, type, op);
+ gimple_set_op (stmt, i, op);
+ }
gimple_assign_set_lhs (stmt, make_ssa_name (type, stmt));
if (gimple_assign_rhs_code (stmt) == POINTER_PLUS_EXPR)
gimple_assign_set_rhs_code (stmt, PLUS_EXPR);
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -fgimple -fdump-tree-lim2-details" } */
+
+int __GIMPLE (ssa,startwith("lim"))
+foo (int x, int n)
+{
+ int i;
+ int r;
+ int _1;
+ int _2;
+ int _6;
+
+ __BB(2):
+ goto __BB7;
+
+ __BB(3):
+ if (i_5 == 17)
+ goto __BB8;
+ else
+ goto __BB4;
+
+ __BB(4):
+ _1 = i_5 & 1;
+ if (_1 != 0)
+ goto __BB5;
+ else
+ goto __BB6;
+
+ __BB(5):
+ _2 = __ABS x_8(D);
+ r_9 = _2 / 5;
+ goto __BB6;
+
+ __BB(6):
+ r_3 = __PHI (__BB5: r_9, __BB4: r_4);
+ i_10 = i_5 + 1;
+ goto __BB7;
+
+ __BB(7,loop_header(1)):
+ r_4 = __PHI (__BB2: 1, __BB6: r_3);
+ i_5 = __PHI (__BB2: 0, __BB6: i_10);
+ if (i_5 < n_7(D))
+ goto __BB3;
+ else
+ goto __BB8;
+
+ __BB(8):
+ _6 = __PHI (__BB3: 0, __BB7: r_4);
+ return _6;
+}
+
+/* { dg-final { scan-tree-dump-times "Moving statement" 2 "lim2" } } */
+/* { dg-final { scan-tree-dump "ABSU_EXPR" "lim2" } } */