The PR127377 fix fails to consider head padding when setting the
new size after pruning the tail. Fix that.
Bootstrap and regtest running on x86_64-unknown-linux-gnu, will push
when that succeeds.
Richard.
PR tree-optimization/128322
* tree-ssa-sccvn.cc (vn_walk_cb_data::push_partial_def):
Properly consider head padding when pruning the tail for
a non-constant def.
* gcc.dg/torture/pr128322.c: New testcase.
---
gcc/testsuite/gcc.dg/torture/pr128322.c | 24 ++++++++++++++++++++++++
gcc/tree-ssa-sccvn.cc | 5 +++--
2 files changed, 27 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/torture/pr128322.c
diff --git a/gcc/testsuite/gcc.dg/torture/pr128322.c
b/gcc/testsuite/gcc.dg/torture/pr128322.c
new file mode 100644
index 00000000000..244fa3bed7d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr128322.c
@@ -0,0 +1,24 @@
+/* { dg-do run } */
+/* { dg-require-effective-target int32plus } */
+
+struct A { unsigned long long lo : 32, y : 19, rest : 13; };
+struct BF { unsigned long long x0:4, x1:8, x2:31, x3:3, x4:4, x5:14; };
+union U { unsigned char b[8]; struct A a; struct BF bf; };
+
+__attribute__((noipa)) unsigned
+f(union U *p, unsigned v)
+{
+ p->b[6] = 209;
+ p->a.y = v;
+ p->b[5] = 39;
+ return p->bf.x4;
+}
+
+int main()
+{
+ static union U x;
+ unsigned r = f(&x, 0x30000);
+ if (r != 12)
+ __builtin_abort();
+ return 0;
+}
diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc
index 7d97bce77fa..49557bb637a 100644
--- a/gcc/tree-ssa-sccvn.cc
+++ b/gcc/tree-ssa-sccvn.cc
@@ -2081,8 +2081,9 @@ vn_walk_cb_data::push_partial_def (pd_data pd,
pd.offset += o;
}
if (pd.size + pd.offset > offseti + maxsizei)
- pd.size = maxsizei + ((pd.size + pd.offset - (offseti + maxsizei))
- % BITS_PER_UNIT);
+ pd.size = ((offseti - pd.offset + maxsizei)
+ + ((pd.size + pd.offset - (offseti + maxsizei))
+ % BITS_PER_UNIT));
}
pd.offset -= offseti;
base-commit: 44c0f794dd4129f279ca9010955095307b981b55
--
2.51.0