aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/pr23115.c29
-rw-r--r--gcc/tree-if-conv.c13
4 files changed, 49 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b8ba8d3..4f792d3 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2005-11-08 Devang Patel <dpatel@apple.com>
+
+ PR tree-optimization/23115
+ * tree-if-conv.c (find_phi_replacement_condition): Check domninated_by
+ relation.
+
2005-11-08 Joseph S. Myers <joseph@codesourcery.com>
* config/rs6000/t-fprules (MULTILIB_MATCHES_FLOAT): Include
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6d4d60d..6ea0741 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2005-11-08 Devang Patel <dpatel@apple.com>
+
+ PR tree-optimization/23115
+ * gcc.dg/tree-ssa/pr23115.c: New.
+
2005-11-08 David Edelsohn <edelsohn@gnu.org>
* g++.dg/ext/altivec-{1-13}.C: XFAIL on AIX and SPE.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr23115.c b/gcc/testsuite/gcc.dg/tree-ssa/pr23115.c
new file mode 100644
index 0000000..6a52aaf
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr23115.c
@@ -0,0 +1,29 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -ftree-vectorize" } */
+
+extern void abort (void);
+
+#define MIN2(a,b) (((a)<(b)) ? (a) : (b))
+#define MAX2(a,b) (((a)>(b)) ? (a) : (b))
+
+double p[2] = { 4., 5. };
+
+int main()
+{
+ long j;
+ double R, n, x;
+
+ n = 1.e300;
+ x = -1.e300;
+ for( j=0; j < 2; j++ )
+ {
+ x = MAX2(x,p[j]);
+ n = MIN2(n,p[j]);
+ }
+ R = x-n;
+
+ if( R < 0.1 )
+ abort ();
+
+ return 0;
+}
diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c
index 303ae2b..5d8375d 100644
--- a/gcc/tree-if-conv.c
+++ b/gcc/tree-if-conv.c
@@ -679,7 +679,7 @@ find_phi_replacement_condition (struct loop *loop,
S2: x = c ? b : a;
S2 is preferred over S1. Make 'b' first_bb and use its condition.
-
+
2) Do not make loop header first_bb.
3)
@@ -691,7 +691,10 @@ find_phi_replacement_condition (struct loop *loop,
S3: x = (c == d) ? b : a;
S3 is preferred over S1 and S2*, Make 'b' first_bb and use
- its condition. */
+ its condition.
+
+ 4) If pred B is dominated by pred A then use pred B's condition.
+ See PR23115. */
/* Select condition that is not TRUTH_NOT_EXPR. */
tmp_cond = first_bb->aux;
@@ -703,8 +706,10 @@ find_phi_replacement_condition (struct loop *loop,
second_bb = tmp_bb;
}
- /* Check if FIRST_BB is loop header or not. */
- if (first_bb == loop->header)
+ /* Check if FIRST_BB is loop header or not and make sure that
+ FIRST_BB does not dominate SECOND_BB. */
+ if (first_bb == loop->header
+ || dominated_by_p (CDI_DOMINATORS, second_bb, first_bb))
{
tmp_cond = second_bb->aux;
if (TREE_CODE (tmp_cond) == TRUTH_NOT_EXPR)