diff options
author | Jakub Jelinek <jakub@redhat.com> | 2024-01-08 13:59:15 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2024-01-08 13:59:15 +0100 |
commit | 8c0dd8a6ff85d6e7b38957f2da400f5cfa8fef6b (patch) | |
tree | d0941665a5557310d80e4e5d5dcdb906d540fc69 /gcc/testsuite/gcc.c-torture | |
parent | efef8d7ff43c6c489fd6e7c52d71494d21324c87 (diff) | |
download | gcc-8c0dd8a6ff85d6e7b38957f2da400f5cfa8fef6b.zip gcc-8c0dd8a6ff85d6e7b38957f2da400f5cfa8fef6b.tar.gz gcc-8c0dd8a6ff85d6e7b38957f2da400f5cfa8fef6b.tar.bz2 |
gimplify: Fix ICE in recalculate_side_effects [PR113228]
The following testcase ICEs during regimplificatgion since the addition of
(convert (eqne zero_one_valued_p@0 INTEGER_CST@1))
simplification. That simplification is novel in the sense that in
gimplify_expr it can turn an expression (comparison in particular) into
a SSA_NAME. Normally when gimplify_expr sees originally a SSA_NAME, it does
case SSA_NAME:
/* Allow callbacks into the gimplifier during optimization. */
ret = GS_ALL_DONE;
break;
and doesn't try to recalculate side effects because of that, but in this
case gimplify_expr normally enters the:
default:
switch (TREE_CODE_CLASS (TREE_CODE (*expr_p)))
{
case tcc_comparison:
then does
*expr_p = gimple_boolify (*expr_p);
and then
*expr_p = fold_convert_loc (input_location,
org_type, *expr_p);
with this new match.pd simplification turns that tcc_comparison class
into SSA_NAME. Unlike the outer SSA_NAME handling though, this falls
through into
recalculate_side_effects (*expr_p);
dont_recalculate:
break;
but unfortunately recalculate_side_effects doesn't handle SSA_NAME and ICEs
on it.
SSA_NAMEs don't ever have TREE_SIDE_EFFECTS set on those, so the following
patch fixes it by handling it similarly to the tcc_constant case.
2024-01-08 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/113228
* gimplify.cc (recalculate_side_effects): Do nothing for SSA_NAMEs.
* gcc.c-torture/compile/pr113228.c: New test.
Diffstat (limited to 'gcc/testsuite/gcc.c-torture')
-rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/pr113228.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr113228.c b/gcc/testsuite/gcc.c-torture/compile/pr113228.c new file mode 100644 index 0000000..f460184 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr113228.c @@ -0,0 +1,17 @@ +/* PR tree-optimization/113228 */ + +int a, b, c, d, i; + +void +foo (void) +{ + int k[3] = {}; + int *l = &a; + for (d = 0; c; c--) + for (i = 0; i <= 9; i++) + { + for (b = 1; b <= 4; b++) + k[0] = k[0] == 0; + *l |= k[d]; + } +} |