aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2019-11-29 08:05:03 +0000
committerRichard Biener <rguenther@suse.de>2019-11-29 08:05:03 +0000
commit3e6b48e7b3bc78f16d7cb785f7438616e0b67e52 (patch)
tree363be524c513dea66ba05c50050f4acbe8e50312
parentd524c95a454061fcf38be6dfaafa3c757a63541c (diff)
2019-11-29 Richard Biener <rguenther@suse.de>
PR tree-optimization/92704 * tree-if-conv.c (combine_blocks): Deal with virtual PHIs in loops performing only loads. * gcc.dg/torture/pr92704.c: New testcase. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@278828 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr92704.c24
-rw-r--r--gcc/tree-if-conv.c9
4 files changed, 44 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b89f404a8b8..1ef3bc2de74 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2019-11-29 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/92704
+ * tree-if-conv.c (combine_blocks): Deal with virtual PHIs
+ in loops performing only loads.
+
2019-11-29 Julian Brown <julian@codesourcery.com>
* builtin-types.def (BT_DFLOAT32_PTR, BT_DFLOAT64_PTR,
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f5bb0d2113e..b787896dd57 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2019-11-29 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/92704
+ * gcc.dg/torture/pr92704.c: New testcase.
+
2019-11-29 Joseph Myers <joseph@codesourcery.com>
* objc.dg/attributes/gnu2x-attr-syntax-1.m: New test.
diff --git a/gcc/testsuite/gcc.dg/torture/pr92704.c b/gcc/testsuite/gcc.dg/torture/pr92704.c
new file mode 100644
index 00000000000..79994a39b54
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr92704.c
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-fexceptions -fnon-call-exceptions -fno-tree-dce -ftree-loop-if-convert" } */
+int zr, yx;
+
+void __attribute__ ((simd))
+oj (int rd, int q7)
+{
+ int wo = (__UINTPTR_TYPE__)&rd;
+
+ while (q7 < 1)
+ {
+ int kv;
+ short int v3;
+
+ for (v3 = 0; v3 < 82; v3 += 3)
+ {
+ }
+
+ kv = zr ? 0 : v3;
+ yx = kv < rd;
+ zr = zr && yx;
+ ++q7;
+ }
+}
diff --git a/gcc/tree-if-conv.c b/gcc/tree-if-conv.c
index 33d6cddb460..d2e40d43373 100644
--- a/gcc/tree-if-conv.c
+++ b/gcc/tree-if-conv.c
@@ -2624,6 +2624,11 @@ combine_blocks (class loop *loop)
vphi = get_virtual_phi (bb);
if (vphi)
{
+ /* When there's just loads inside the loop a stray virtual
+ PHI merging the uses can appear, update last_vdef from
+ it. */
+ if (!last_vdef)
+ last_vdef = gimple_phi_arg_def (vphi, 0);
imm_use_iterator iter;
use_operand_p use_p;
gimple *use_stmt;
@@ -2655,6 +2660,10 @@ combine_blocks (class loop *loop)
if (gimple_vdef (stmt))
last_vdef = gimple_vdef (stmt);
}
+ else
+ /* If this is the first load we arrive at update last_vdef
+ so we handle stray PHIs correctly. */
+ last_vdef = gimple_vuse (stmt);
if (predicated[i])
{
ssa_op_iter i;