From 77d1d8e01ff69521974d20c0f3fef75e3c2f8614 Mon Sep 17 00:00:00 2001 From: "James A. Morrison" Date: Thu, 28 Jul 2005 04:40:05 +0000 Subject: [PATCH] re PR rtl-optimization/23047 (Combine ignores flag_wrapv) 2005-07-27 James A. Morrison PR rtl-optimization/23047 * simplify-rtx.c (simplify_const_relational_operation): Respect flag_wrapv for comparisons with ABS. From-SVN: r102459 --- gcc/ChangeLog | 6 ++++++ gcc/simplify-rtx.c | 8 ++++++-- gcc/testsuite/ChangeLog | 8 +++++++- gcc/testsuite/gcc.c-torture/execute/pr23047.c | 16 ++++++++++++++++ gcc/testsuite/gcc.c-torture/execute/pr23047.x | 2 ++ 5 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/execute/pr23047.c create mode 100644 gcc/testsuite/gcc.c-torture/execute/pr23047.x diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b0d7bff72885..d888c82e23fc 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2005-07-25 James A. Morrison + + PR rtl-optimization/23047 + * simplify-rtx.c (simplify_const_relational_operation): Respect + flag_wrapv for comparisons with ABS. + 2005-07-27 James A. Morrison PR tree-optimization/22493 diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index ae1fea7e2e47..e3e29991af8f 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -3236,7 +3236,9 @@ simplify_const_relational_operation (enum rtx_code code, case LT: /* Optimize abs(x) < 0.0. */ - if (trueop1 == CONST0_RTX (mode) && !HONOR_SNANS (mode)) + if (trueop1 == CONST0_RTX (mode) + && !HONOR_SNANS (mode) + && !(flag_wrapv && INTEGRAL_MODE_P (mode))) { tem = GET_CODE (trueop0) == FLOAT_EXTEND ? XEXP (trueop0, 0) : trueop0; @@ -3247,7 +3249,9 @@ simplify_const_relational_operation (enum rtx_code code, case GE: /* Optimize abs(x) >= 0.0. */ - if (trueop1 == CONST0_RTX (mode) && !HONOR_NANS (mode)) + if (trueop1 == CONST0_RTX (mode) + && !HONOR_NANS (mode) + && !(flag_wrapv && INTEGRAL_MODE_P (mode))) { tem = GET_CODE (trueop0) == FLOAT_EXTEND ? XEXP (trueop0, 0) : trueop0; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d2861aade39c..ddf272d68858 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,12 @@ 2005-07-27 James A. Morrison - PR rtl-optimization/22493 + PR rtl-optimization/23047 + * gcc.c-torture/execute/pr23047.c: New test. + * gcc.c-torture/execute/pr23047.x: New. + +2005-07-27 James A. Morrison + + PR tree-optimization/22493 * gcc.c-torture/execute/pr22493-1.c: New test. * gcc.c-torture/execute/pr22493-1.x: New. * gcc.c-torture/execute/vrp-1.c: New test. diff --git a/gcc/testsuite/gcc.c-torture/execute/pr23047.c b/gcc/testsuite/gcc.c-torture/execute/pr23047.c new file mode 100644 index 000000000000..7557fc2beca1 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr23047.c @@ -0,0 +1,16 @@ +#include +extern void abort (); +extern void exit (int); +void f(int i) +{ + i = i > 0 ? i : -i; + if (i<0) + return; + abort (); +} + +int main(int argc, char *argv[]) +{ + f(INT_MIN); + exit (0); +} diff --git a/gcc/testsuite/gcc.c-torture/execute/pr23047.x b/gcc/testsuite/gcc.c-torture/execute/pr23047.x new file mode 100644 index 000000000000..36a58395004c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr23047.x @@ -0,0 +1,2 @@ +set additional_flags "-fwrapv" +return 0