tree-optimization/111070 - fix ICE with recent ifcombine fix

Message ID 20230821080920.40614385B800@sourceware.org
State Unresolved
Headers
Series tree-optimization/111070 - fix ICE with recent ifcombine fix |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Richard Biener Aug. 21, 2023, 8:08 a.m. UTC
  We now got test coverage for non-SSA name bits so the following amends
the SSA_NAME_OCCURS_IN_ABNORMAL_PHI checks.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

Richard.

	PR tree-optimization/111070
	* tree-ssa-ifcombine.cc (ifcombine_ifandif): Check we have
	an SSA name before checking SSA_NAME_OCCURS_IN_ABNORMAL_PHI.

	* gcc.dg/pr111070.c: New testcase.
---
 gcc/testsuite/gcc.dg/pr111070.c | 20 ++++++++++++++++++++
 gcc/tree-ssa-ifcombine.cc       |  9 ++++++---
 2 files changed, 26 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/pr111070.c
  

Patch

diff --git a/gcc/testsuite/gcc.dg/pr111070.c b/gcc/testsuite/gcc.dg/pr111070.c
new file mode 100644
index 00000000000..1ebc7adf782
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr111070.c
@@ -0,0 +1,20 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O" } */
+
+/* common */
+char c;
+/* arrays must be 8 byte aligned, regardless of size */
+char c_ary[1];
+
+/* data */
+char d = 1;
+char d_ary[1] = {1};
+
+int main ()
+{
+  if (((unsigned long)&c_ary[0] & 7) != 0)
+    return 1;
+  if (((unsigned long)&d_ary[0] & 7) != 0)
+    return 1;
+  return 0;
+}
diff --git a/gcc/tree-ssa-ifcombine.cc b/gcc/tree-ssa-ifcombine.cc
index d5701e8c407..46b076804f4 100644
--- a/gcc/tree-ssa-ifcombine.cc
+++ b/gcc/tree-ssa-ifcombine.cc
@@ -430,7 +430,8 @@  ifcombine_ifandif (basic_block inner_cond_bb, bool inner_inv,
     {
       tree t, t2;
 
-      if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name1))
+      if (TREE_CODE (name1) == SSA_NAME
+	  && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name1))
 	return false;
 
       /* Do it.  */
@@ -489,8 +490,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))
+      if ((TREE_CODE (name1) == SSA_NAME
+	   && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name1))
+	  || (TREE_CODE (name2) == SSA_NAME
+	      && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name2)))
 	return false;
 
       /* Find the common name which is bit-tested.  */