[gcc r14-6804] lower-bitint: Handle unreleased SSA_NAMEs from earlier passes gracefully [PR113102]
Jakub Jelinek
jakub@gcc.gnu.org
Fri Dec 22 11:30:28 GMT 2023
https://gcc.gnu.org/g:f5198f0264e773d3b5d55f09a579313b0b231527
commit r14-6804-gf5198f0264e773d3b5d55f09a579313b0b231527
Author: Jakub Jelinek <jakub@redhat.com>
Date: Fri Dec 22 12:28:06 2023 +0100
lower-bitint: Handle unreleased SSA_NAMEs from earlier passes gracefully [PR113102]
On the following testcase earlier passes leave around an unreleased
SSA_NAME - non-GIMPLE_NOP SSA_NAME_DEF_STMT which isn't in any bb.
The following patch makes bitint lowering resistent against those,
the first hunk is where we'd for certain kinds of stmts try to ammend
them and the latter is where we'd otherwise try to remove them,
neither of which works. The other loops over all SSA_NAMEs either
already also check gimple_bb (SSA_NAME_DEF_STMT (s)) or it doesn't
matter that much if we process it or not (worst case it means e.g.
the pass wouldn't return early even when it otherwise could).
2023-12-22 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/113102
* gimple-lower-bitint.cc (gimple_lower_bitint): Handle unreleased
large/huge _BitInt SSA_NAMEs.
* gcc.dg/bitint-59.c: New test.
Diff:
---
gcc/gimple-lower-bitint.cc | 7 ++++++-
gcc/testsuite/gcc.dg/bitint-59.c | 14 ++++++++++++++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/gcc/gimple-lower-bitint.cc b/gcc/gimple-lower-bitint.cc
index 880938999f4..0910477fbbe 100644
--- a/gcc/gimple-lower-bitint.cc
+++ b/gcc/gimple-lower-bitint.cc
@@ -5827,7 +5827,7 @@ gimple_lower_bitint (void)
tree_code rhs_code;
/* Unoptimize certain constructs to simpler alternatives to
avoid having to lower all of them. */
- if (is_gimple_assign (stmt))
+ if (is_gimple_assign (stmt) && gimple_bb (stmt))
switch (rhs_code = gimple_assign_rhs_code (stmt))
{
default:
@@ -6690,6 +6690,11 @@ gimple_lower_bitint (void)
release_ssa_name (s);
continue;
}
+ if (gimple_bb (g) == NULL)
+ {
+ release_ssa_name (s);
+ continue;
+ }
if (gimple_code (g) != GIMPLE_ASM)
{
gimple_stmt_iterator gsi = gsi_for_stmt (g);
diff --git a/gcc/testsuite/gcc.dg/bitint-59.c b/gcc/testsuite/gcc.dg/bitint-59.c
new file mode 100644
index 00000000000..4868315a3ba
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/bitint-59.c
@@ -0,0 +1,14 @@
+/* PR tree-optimization/113102 */
+/* { dg-do compile { target bitint } } */
+/* { dg-options "-std=c23 -O2" } */
+
+unsigned x;
+
+#if __BITINT_MAXWIDTH__ >= 191
+void
+foo (void)
+{
+ unsigned _BitInt(191) b = x;
+ ~(b >> x) % 3;
+}
+#endif
More information about the Gcc-cvs
mailing list