Commit 8e2c037d by Richard Biener Committed by Richard Biener

gimple-fold.c (arith_code_with_undefined_signed_overflow): Add ABS_EXPR.

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.

	* gcc.dg/tree-ssa/ssa-lim-13.c: New testcase.

From-SVN: r271501
parent e1542427
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.
......
......@@ -7329,6 +7329,7 @@ arith_code_with_undefined_signed_overflow (tree_code code)
{
switch (code)
{
case ABS_EXPR:
case PLUS_EXPR:
case MINUS_EXPR:
case MULT_EXPR:
......@@ -7361,12 +7362,15 @@ rewrite_to_defined_overflow (gimple *stmt)
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);
......
2019-05-22 Richard Biener <rguenther@suse.de>
* gcc.dg/tree-ssa/ssa-lim-13.c: New testcase.
2019-05-22 Hans-Peter Nilsson <hp@axis.com>
PR middle-end/90553
......
/* { 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" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment