From 01e93ec4e055b2ae6cfe76ad9685a2eca155f99b Mon Sep 17 00:00:00 2001 From: uros Date: Tue, 4 Mar 2008 13:57:27 +0000 Subject: [PATCH] PR middle-end/35456 * fold-const.c (fold_cond_expr_with_comparison): Prevent transformations for modes that have signed zeros. * ifcvt.c (noce_try_abs): Ditto. testsuite/ChangeLog: PR middle-end/35456 * gcc.c-torture/execute/pr35456.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@132863 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 16 +++++++++++++--- gcc/fold-const.c | 13 ++++++++----- gcc/ifcvt.c | 4 ++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.c-torture/execute/pr35456.c | 21 +++++++++++++++++++++ 5 files changed, 51 insertions(+), 8 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/execute/pr35456.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 459f39200a1..4cbddb63a1c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2008-03-04 Uros Bizjak + + PR middle-end/35456 + * fold-const.c (fold_cond_expr_with_comparison): Prevent + transformations for modes that have signed zeros. + * ifcvt.c (noce_try_abs): Ditto. + 2008-03-04 Joseph Myers * config/i386/i386.c (override_options): Force @@ -251,7 +258,8 @@ struct rdg_vertex_info, rdg_vertex_for_stmt): New. (create_rdg_edge_for_ddr, create_rdg_vertices): Cleaned up. (stmts_from_loop): Skip LABEL_EXPR. - (hash_stmt_vertex_info, eq_stmt_vertex_info, hash_stmt_vertex_del): New. + (hash_stmt_vertex_info, eq_stmt_vertex_info, hash_stmt_vertex_del): + New. (build_rdg): Initialize rdg->indices htab. (free_rdg, stores_from_loop, ref_base_address, rdg_defs_used_in_other_loops_p, have_similar_memory_accesses, @@ -260,7 +268,8 @@ * tree-data-ref.h: Depend on tree-chrec.h. (debug_data_dependence_relations, free_data_ref): Declared. (same_access_functions): ... here. - (ddr_is_anti_dependent, ddrs_have_anti_deps, ddr_dependence_level): New. + (ddr_is_anti_dependent, ddrs_have_anti_deps, ddr_dependence_level): + New. (struct rdg_vertex): Add has_mem_write and has_mem_reads. (RDGV_HAS_MEM_WRITE, RDGV_HAS_MEM_READS, RDG_STMT, RDG_MEM_WRITE_STMT, RDG_MEM_READS_STMT): New. @@ -270,7 +279,8 @@ (struct rdg_edge): Add level. (RDGE_LEVEL): New. (free_rdg, stores_from_loop, remove_similar_memory_refs, - rdg_defs_used_in_other_loops_p, have_similar_memory_accesses): Declared. + rdg_defs_used_in_other_loops_p, have_similar_memory_accesses): + Declared. (rdg_has_similar_memory_accesses): New. * tree-vect-analyze.c: Remove unused static decls. * lambda.h (dependence_level): New. diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 6a70e179aa2..f6466f7a830 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -5072,9 +5072,10 @@ fold_cond_expr_with_comparison (tree type, tree arg0, tree arg1, tree arg2) Note that all these transformations are correct if A is NaN, since the two alternatives (A and -A) are also NaNs. */ - if ((FLOAT_TYPE_P (TREE_TYPE (arg01)) - ? real_zerop (arg01) - : integer_zerop (arg01)) + if (!HONOR_SIGNED_ZEROS (TYPE_MODE (type)) + && (FLOAT_TYPE_P (TREE_TYPE (arg01)) + ? real_zerop (arg01) + : integer_zerop (arg01)) && ((TREE_CODE (arg2) == NEGATE_EXPR && operand_equal_p (TREE_OPERAND (arg2, 0), arg1, 0)) /* In the case that A is of the form X-Y, '-A' (arg2) may @@ -5127,7 +5128,8 @@ fold_cond_expr_with_comparison (tree type, tree arg0, tree arg1, tree arg2) both transformations are correct when A is NaN: A != 0 is then true, and A == 0 is false. */ - if (integer_zerop (arg01) && integer_zerop (arg2)) + if (!HONOR_SIGNED_ZEROS (TYPE_MODE (type)) + && integer_zerop (arg01) && integer_zerop (arg2)) { if (comp_code == NE_EXPR) return pedantic_non_lvalue (fold_convert (type, arg1)); @@ -5161,7 +5163,8 @@ fold_cond_expr_with_comparison (tree type, tree arg0, tree arg1, tree arg2) a number and A is not. The conditions in the original expressions will be false, so all four give B. The min() and max() versions would give a NaN instead. */ - if (operand_equal_for_comparison_p (arg01, arg2, arg00) + if (!HONOR_SIGNED_ZEROS (TYPE_MODE (type)) + && operand_equal_for_comparison_p (arg01, arg2, arg00) /* Avoid these transformations if the COND_EXPR may be used as an lvalue in the C++ front-end. PR c++/19199. */ && (in_gimple_form diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c index 4fd98d010d3..cab4fbdf6b1 100644 --- a/gcc/ifcvt.c +++ b/gcc/ifcvt.c @@ -1738,6 +1738,10 @@ noce_try_abs (struct noce_if_info *if_info) rtx cond, earliest, target, seq, a, b, c; int negate; + /* Reject modes with signed zeros. */ + if (HONOR_SIGNED_ZEROS (GET_MODE (if_info->x))) + return FALSE; + /* Recognize A and B as constituting an ABS or NABS. The canonical form is a branch around the negation, taken when the object is the first operand of a comparison against 0 that evaluates to true. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7aeb04091de..7b62ebf98a3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-03-04 Uros Bizjak + + PR middle-end/35456 + * gcc.c-torture/execute/pr35456.c: New test. + 2008-03-04 Joseph Myers * gcc.target/i386/sse-10.c: Don't use diff --git a/gcc/testsuite/gcc.c-torture/execute/pr35456.c b/gcc/testsuite/gcc.c-torture/execute/pr35456.c new file mode 100644 index 00000000000..175a0b2abfa --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr35456.c @@ -0,0 +1,21 @@ +extern void abort (void); + +double +__attribute__ ((noinline)) +not_fabs (double x) +{ + return x >= 0.0 ? x : -x; +} + +int main() +{ + double x = -0.0; + double y; + + y = not_fabs (x); + + if (!__builtin_signbit (y)) + abort(); + + return 0; +} -- 2.11.0