loop interchange already handles bitfield accesses by dropping to
the base, do the same for BIT_FIELD_REFs.
Bootstrap and regtest running on x86_64-unknown-linux-gnu, will push
if that succeeds.
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.
---
gcc/gimple-loop-interchange.cc | 4 ++++
gcc/testsuite/gcc.dg/torture/pr128878.c | 12 ++++++++++++
2 files changed, 16 insertions(+)
create mode 100644 gcc/testsuite/gcc.dg/torture/pr128878.c
diff --git a/gcc/gimple-loop-interchange.cc b/gcc/gimple-loop-interchange.cc
index 7f8ca2f9d57..97da816df62 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 00000000000..a983140b012
--- /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);
+}
--
2.51.0