aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorAndrew Pinski <apinski@marvell.com>2021-11-18 23:38:30 +0000
committerAndrew Pinski <apinski@marvell.com>2021-11-19 07:18:23 +0000
commit09d462146b3107c665265b11ad925c61a91c6efb (patch)
tree03e6954073123ca810cfb28a51ede5da2d1ec1fe /gcc
parent527e54a431473cc497204226a21f2831d2375e66 (diff)
downloadgcc-09d462146b3107c665265b11ad925c61a91c6efb.zip
gcc-09d462146b3107c665265b11ad925c61a91c6efb.tar.gz
gcc-09d462146b3107c665265b11ad925c61a91c6efb.tar.bz2
Fix PR 103317, ICE after PHI-OPT, minmax_replacement producing invalid SSA
The problem is r12-5300-gf98f373dd822b35c allows phiopt to recognize more basic blocks but missed one location where the basic block does not need to be empty but still needs to have a single predecessor. This patch fixes that over sight. OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. PR tree-optimization/103317 gcc/ChangeLog: * tree-ssa-phiopt.c (minmax_replacement): For the non empty middle bb case, check to make sure it has a single predecessor. gcc/testsuite/ChangeLog: * gcc.c-torture/compile/pr103317-1.c: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr103317-1.c13
-rw-r--r--gcc/tree-ssa-phiopt.c3
2 files changed, 16 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr103317-1.c b/gcc/testsuite/gcc.c-torture/compile/pr103317-1.c
new file mode 100644
index 0000000..f9d145e
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr103317-1.c
@@ -0,0 +1,13 @@
+int a, b;
+char c;
+void
+d (void)
+{
+ char e = c;
+ if (b)
+ if (c < 16 - 11)
+ e = 16 - 11;
+ if (e > 8)
+ e = 8;
+ a = e;
+}
diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c
index f043168..1abc4ea 100644
--- a/gcc/tree-ssa-phiopt.c
+++ b/gcc/tree-ssa-phiopt.c
@@ -1780,6 +1780,9 @@ minmax_replacement (basic_block cond_bb, basic_block middle_bb,
gimple *assign = last_and_only_stmt (middle_bb);
tree lhs, op0, op1, bound;
+ if (!single_pred_p (middle_bb))
+ return false;
+
if (!assign
|| gimple_code (assign) != GIMPLE_ASSIGN)
return false;