[gcc r14-12792] gimplify: Allow declarations in recalculate_side_effects [PR126497]
Jakub Jelinek via Gcc-cvs <[email protected]> Sat, 1 Aug 2026 10:29:47 +0000 (GMT)
| Newsgroups | gmane.comp.gcc.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://gcc.gnu.org/g:bbe1892f92c5b76637a53c376e6ff7f8095ca851 commit r14-12792-gbbe1892f92c5b76637a53c376e6ff7f8095ca851 Author: Jakub Jelinek <[email protected]> Date: Fri Jul 31 09:05:50 2026 +0200 gimplify: Allow declarations in recalculate_side_effects [PR126497] The following testcase ICEs, because we decide to fold a comparison into just one of its operands, we call recalculate_side_effects on that and ICE on the assertion that it isn't called on anything unexpected (here PARM_DECL). Already some time ago we had to add an exception for SSA_NAME for the same reason. The tcc_declaration case is slightly different, TREE_SIDE_EFFECTS is sometimes present on those if they are TREE_THIS_VOLATILE, but it is something the FE should take care of when creating those decls, not a business of the gimplifier. 2026-07-31 Jakub Jelinek <[email protected]> PR middle-end/126497 * gimplify.cc (recalculate_side_effects): Return for tcc_declaration. * gcc.dg/bitint-141.c: New test. Reviewed-by: Andrea Pinski <[email protected]> (cherry picked from commit ca867fd9d5ace4ede8289dba9ae731e554bde618) Diff: --- gcc/gimplify.cc | 7 +++++++ gcc/testsuite/gcc.dg/bitint-141.c | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc index 7fdfbe25a8ae..6cc2d1299f04 100644 --- a/gcc/gimplify.cc +++ b/gcc/gimplify.cc @@ -3372,6 +3372,13 @@ recalculate_side_effects (tree t) /* No side-effects. */ return; + case tcc_declaration: + /* These can have side-effects if TREE_THIS_VOLATILE, + but those should be set elsewhere, not in + recalculate_side_effects. Can be triggered e.g. if + a comparison is folded into one of its operands. */ + return; + default: if (code == SSA_NAME) /* No side-effects. */ diff --git a/gcc/testsuite/gcc.dg/bitint-141.c b/gcc/testsuite/gcc.dg/bitint-141.c new file mode 100644 index 000000000000..f3f22bbb0bf3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/bitint-141.c @@ -0,0 +1,19 @@ +/* PR middle-end/126497 */ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-std=c23" } */ + +typedef unsigned _BitInt (1) U; + +U +foo (U a) +{ + U t = a >= 1uwb; + return t; +} + +U +bar (U a) +{ + U t = a == 1uwb; + return t; +}