]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
2018-09-03 Richard Biener <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 3 Sep 2018 14:29:00 +0000 (14:29 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 3 Sep 2018 14:29:00 +0000 (14:29 +0000)
PR tree-optimization/87200
* tree-ssa-sccvn.c (vn_nary_build_or_lookup_1): Valueize a
simplify result.

* gcc.dg/torture/pr87200.c: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@264062 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr87200.c [new file with mode: 0644]
gcc/tree-ssa-sccvn.c

index 40795e7ad39d8061e79baf6dba25d9ba310d2d78..981e7063f971b906e4e1680cd2dc7987c1a88311 100644 (file)
@@ -1,3 +1,9 @@
+2018-09-03  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/87200
+       * tree-ssa-sccvn.c (vn_nary_build_or_lookup_1): Valueize a
+       simplify result.
+
 2018-09-03  Martin Liska  <mliska@suse.cz>
 
        PR tree-optimization/87201
index bd06f66b3d6897d485279882d6a15b6efaa17fa1..b44c714d7d20b426e4a2a8557c67a68de9b6f1f6 100644 (file)
@@ -1,3 +1,8 @@
+2018-09-03  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/87200
+       * gcc.dg/torture/pr87200.c: New testcase.
+
 2018-09-03  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/87197
diff --git a/gcc/testsuite/gcc.dg/torture/pr87200.c b/gcc/testsuite/gcc.dg/torture/pr87200.c
new file mode 100644 (file)
index 0000000..a035631
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+
+unsigned long long int ry;
+
+int
+gl (void)
+{
+  long long int my = 0;
+  unsigned long long int *oi = (unsigned long long int *) &my;
+  int s9;
+
+  s9 = !!gl () ? ry : 0;
+  if (s9 != 0)
+    oi = &ry;
+  else
+    {
+      my = ry;
+      *oi += my;
+    }
+
+  return *oi;
+}
+
index 26d093ea05ba6665df4252ac01032a00b52f7542..1f00335885136f54c7151134b35cd95599275559 100644 (file)
@@ -1759,8 +1759,13 @@ vn_nary_build_or_lookup_1 (gimple_match_op *res_op, bool insert)
   gimple *new_stmt = NULL;
   if (res
       && gimple_simplified_result_is_gimple_val (res_op))
-    /* The expression is already available.  */
-    result = res_op->ops[0];
+    {
+      /* The expression is already available.  */
+      result = res_op->ops[0];
+      /* Valueize it, simplification returns sth in AVAIL only.  */
+      if (TREE_CODE (result) == SSA_NAME)
+       result = SSA_VAL (result);
+    }
   else
     {
       tree val = vn_lookup_simplify_result (res_op);