tree-ssa-dom.c (build_and_record_new_cond): Add optional parameter to record a condit...
authorRichard Biener <rguenther@suse.de>
Thu, 2 Jul 2015 07:37:35 +0000 (07:37 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 2 Jul 2015 07:37:35 +0000 (07:37 +0000)
2015-07-02  Richard Biener  <rguenther@suse.de>

* tree-ssa-dom.c (build_and_record_new_cond): Add optional
parameter to record a condition that is false.
(record_conditions): When recording an extra NE_EXPR that is
true also record a EQ_EXPR that is false.

* gcc.dg/tree-ssa/ssa-dom-cse-4.c: New testcase.

From-SVN: r225299

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-4.c [new file with mode: 0644]
gcc/tree-ssa-dom.c

index c9c3c209d92c55b1e96204a29204d942b7792232..90d997fdcb1af20f7dd85795265f68e7890b532e 100644 (file)
@@ -1,3 +1,10 @@
+2015-07-02  Richard Biener  <rguenther@suse.de>
+
+       * tree-ssa-dom.c (build_and_record_new_cond): Add optional
+       parameter to record a condition that is false.
+       (record_conditions): When recording an extra NE_EXPR that is
+       true also record a EQ_EXPR that is false.
+
 2015-07-02  Bin Cheng  <bin.cheng@arm.com>
 
        * tree-ssa-loop-ivopts.c (struct ivopts_data): New field iv_obstack.
index f6903b0f741671c3661307251b959e63f01a6ec7..789f44e8e37c9836e2a9d0a4529d52afc2b9748a 100644 (file)
@@ -1,3 +1,7 @@
+2015-07-02  Richard Biener  <rguenther@suse.de>
+
+       * gcc.dg/tree-ssa/ssa-dom-cse-4.c: New testcase.
+
 2015-07-01  H.J. Lu  <hongjiu.lu@intel.com>
 
        * gcc.target/i386/mpx/pr66568.c (exit): New prototype.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-4.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-4.c
new file mode 100644 (file)
index 0000000..cc9dde9
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-optimized" } */
+
+extern void abort (void);
+
+unsigned int
+foo (unsigned int x, unsigned int y)
+{
+  unsigned int z;
+
+  if (x >= y)
+    return 1;
+
+  if (y == x)
+    abort ();
+
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-not "abort" "optimized" } } */
index e45b78c411aa9f9c8f486763ec6a6a3748a5be4d..698f78a52396efcc9849801a38fa60b807d48089 100644 (file)
@@ -813,7 +813,8 @@ free_all_edge_infos (void)
 static void
 build_and_record_new_cond (enum tree_code code,
                            tree op0, tree op1,
-                           vec<cond_equivalence> *p)
+                           vec<cond_equivalence> *p,
+                          bool val = true)
 {
   cond_equivalence c;
   struct hashable_expr *cond = &c.cond;
@@ -826,7 +827,7 @@ build_and_record_new_cond (enum tree_code code,
   cond->ops.binary.opnd0 = op0;
   cond->ops.binary.opnd1 = op1;
 
-  c.value = boolean_true_node;
+  c.value = val ? boolean_true_node : boolean_false_node;
   p->safe_push (c);
 }
 
@@ -865,6 +866,8 @@ record_conditions (struct edge_info *edge_info, tree cond, tree inverted)
                                 op0, op1, &edge_info->cond_equivalences);
       build_and_record_new_cond (NE_EXPR, op0, op1,
                                 &edge_info->cond_equivalences);
+      build_and_record_new_cond (EQ_EXPR, op0, op1,
+                                &edge_info->cond_equivalences, false);
       break;
 
     case GE_EXPR: