https://gcc.gnu.org/g:5e3007f353e16c7d3e641aeb0770a7976f009eda
commit r17-6468-g5e3007f353e16c7d3e641aeb0770a7976f009eda Author: Richard Biener <[email protected]> Date: Thu Nov 19 14:20:08 2026 +0100 tree-optimization/128878 - handle BIT_FIELD_REF in compute_access_stride loop interchange already handles bitfield accesses by dropping to the base, do the same for BIT_FIELD_REFs. PR tree-optimization/128878 * gimple-loop-interchange.cc (compute_access_stride): For a BIT_FIELD_REF ref, use the address of its base for analysis. * gcc.dg/torture/pr128878.c: New testcase. Diff: --- gcc/gimple-loop-interchange.cc | 4 ++++ gcc/testsuite/gcc.dg/torture/pr128878.c | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/gcc/gimple-loop-interchange.cc b/gcc/gimple-loop-interchange.cc index 7f8ca2f9d57b..97da816df621 100644 --- a/gcc/gimple-loop-interchange.cc +++ b/gcc/gimple-loop-interchange.cc @@ -1323,6 +1323,10 @@ compute_access_stride (class loop *&loop_nest, class loop *loop, else return; } + else if (TREE_CODE (ref) == BIT_FIELD_REF) + /* We can't take address of bitfields. Just use address of the + base, for analysis of the strides that shouldn't matter. */ + ref = TREE_OPERAND (ref, 0); tree scev_base = build_fold_addr_expr (ref); tree scev = analyze_scalar_evolution (loop, scev_base); if (chrec_contains_undetermined (scev)) diff --git a/gcc/testsuite/gcc.dg/torture/pr128878.c b/gcc/testsuite/gcc.dg/torture/pr128878.c new file mode 100644 index 000000000000..a983140b012e --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr128878.c @@ -0,0 +1,12 @@ +/* { dg-do compile { target bitint575 } } */ + +struct a { _BitInt(35) x : 6; _BitInt(575) b : 455; }; +void c (struct a *); + +void d (void) +{ + struct a e[5]; + for (int f = 0; f < 5; f++) + e[f].b = 0; + c (e); +}
