* [PATCH] tree-optimization/111039 - abnormals and bit test merging
@ 2023-08-17 13:26 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2023-08-17 13:26 UTC (permalink / raw)
To: gcc-patches
The following guards the bit test merging code in if-combine against
the appearance of SSA names used in abnormal PHIs.
Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.
PR tree-optimization/111039
* tree-ssa-ifcombine.cc (ifcombine_ifandif): Check for
SSA_NAME_OCCURS_IN_ABNORMAL_PHI.
* gcc.dg/pr111039.c: New testcase.
---
gcc/testsuite/gcc.dg/pr111039.c | 15 +++++++++++++++
gcc/tree-ssa-ifcombine.cc | 7 +++++++
2 files changed, 22 insertions(+)
create mode 100644 gcc/testsuite/gcc.dg/pr111039.c
diff --git a/gcc/testsuite/gcc.dg/pr111039.c b/gcc/testsuite/gcc.dg/pr111039.c
new file mode 100644
index 00000000000..bec9983b35f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr111039.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O" } */
+
+int _setjmp ();
+void abcd ();
+void abcde ();
+void compiler_corruption_function(int flags)
+{
+ int nowait = flags & 1048576, isexpand = flags & 8388608;
+ abcd();
+ _setjmp(flags);
+ if (nowait && isexpand)
+ flags &= 0;
+ abcde();
+}
diff --git a/gcc/tree-ssa-ifcombine.cc b/gcc/tree-ssa-ifcombine.cc
index 58e19c1508e..d5701e8c407 100644
--- a/gcc/tree-ssa-ifcombine.cc
+++ b/gcc/tree-ssa-ifcombine.cc
@@ -430,6 +430,9 @@ ifcombine_ifandif (basic_block inner_cond_bb, bool inner_inv,
{
tree t, t2;
+ if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name1))
+ return false;
+
/* Do it. */
gsi = gsi_for_stmt (inner_cond);
t = fold_build2 (LSHIFT_EXPR, TREE_TYPE (name1),
@@ -486,6 +489,10 @@ ifcombine_ifandif (basic_block inner_cond_bb, bool inner_inv,
gimple_stmt_iterator gsi;
tree t;
+ if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name1)
+ || SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name2))
+ return false;
+
/* Find the common name which is bit-tested. */
if (name1 == name2)
;
--
2.35.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-08-17 13:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-17 13:26 [PATCH] tree-optimization/111039 - abnormals and bit test merging Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).