This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR44683


This fixes PR44683 - we can't just record equivalences on the
false edge when the predicate is NE_EXPR, instead we have to
check the predicate of the inverted condition, otherwise we'd
get x != 0.0 wrong wrt signed zeros.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk
and the branches.

Richard.

2010-06-27  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/44683
	* tree-ssa-dom.c (record_edge_info): Record equivalences for the
	false edge from the inverted condition.

	* gcc.c-torture/execute/pr44683.c: New testcase.

Index: gcc/tree-ssa-dom.c
===================================================================
*** gcc/tree-ssa-dom.c	(revision 161455)
--- gcc/tree-ssa-dom.c	(working copy)
*************** record_edge_info (basic_block bb)
*** 1635,1641 ****
                edge_info = allocate_edge_info (false_edge);
                record_conditions (edge_info, inverted, cond);
  
!               if (code == NE_EXPR)
                  {
                    edge_info->lhs = op1;
                    edge_info->rhs = op0;
--- 1635,1641 ----
                edge_info = allocate_edge_info (false_edge);
                record_conditions (edge_info, inverted, cond);
  
!               if (TREE_CODE (inverted) == EQ_EXPR)
                  {
                    edge_info->lhs = op1;
                    edge_info->rhs = op0;
*************** record_edge_info (basic_block bb)
*** 1662,1668 ****
                edge_info = allocate_edge_info (false_edge);
                record_conditions (edge_info, inverted, cond);
  
!               if (TREE_CODE (cond) == NE_EXPR)
                  {
                    edge_info->lhs = op0;
                    edge_info->rhs = op1;
--- 1662,1668 ----
                edge_info = allocate_edge_info (false_edge);
                record_conditions (edge_info, inverted, cond);
  
!               if (TREE_CODE (inverted) == EQ_EXPR)
                  {
                    edge_info->lhs = op0;
                    edge_info->rhs = op1;
Index: gcc/testsuite/gcc.c-torture/execute/pr44683.c
===================================================================
*** gcc/testsuite/gcc.c-torture/execute/pr44683.c	(revision 0)
--- gcc/testsuite/gcc.c-torture/execute/pr44683.c	(revision 0)
***************
*** 0 ****
--- 1,18 ----
+ int __attribute__((noinline,noclone))
+ copysign_bug (double x)
+ {
+   if (x != 0.0 && (x * 0.5 == x))
+     return 1;
+   if (__builtin_copysign(1.0, x) < 0.0)
+     return 2;
+   else
+     return 3;
+ }
+ int main(void)
+ {
+   double x = -0.0;
+   if (copysign_bug (x) != 2)
+     __builtin_abort ();
+   return 0;
+ }
+ 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]