[v2] testcase: Add testcase for shrink wrapping of vector<int>::push_back [PR118502]
Checks
Context |
Check |
Description |
rivoscibot/toolchain-ci-rivos-lint |
success
|
Lint passed
|
rivoscibot/toolchain-ci-rivos-apply-patch |
success
|
Patch applied
|
rivoscibot/toolchain-ci-rivos-build--newlib-rv64gcv-lp64d-multilib |
success
|
Build passed
|
rivoscibot/toolchain-ci-rivos-build--linux-rv64gc_zba_zbb_zbc_zbs-lp64d-multilib |
success
|
Build passed
|
rivoscibot/toolchain-ci-rivos-build--linux-rv64gcv-lp64d-multilib |
success
|
Build passed
|
rivoscibot/toolchain-ci-rivos-test |
success
|
Testing passed
|
Commit Message
LLVM folks noticed that GCC was shrink wrapping the call to vector<int>::push_back.
So I thought it was a good idea to commit a testcase to make sure GCC does not regress
in this area unknowning.
Note the shrink wrapping started with r15-1619-g3b9b8d6cfdf593.
Note this enables the testcase for x86_64 (!ia32), powerpc, aarch64 and riscv which I tested
via godbolt to see the shrink wrapping occurs. Also tested the testcase for both
x86_64-linux-gnu and aarch64-linux-gnu to make sure I got the target selects correct.
Changes since v1:
* v2: Fix some comments typos that was mentioned in the bug report.
PR rtl-optimization/118502
gcc/testsuite/ChangeLog:
* g++.dg/opt/shrink-wrapping-vector-1.C: New test.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
---
.../g++.dg/opt/shrink-wrapping-vector-1.C | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
create mode 100644 gcc/testsuite/g++.dg/opt/shrink-wrapping-vector-1.C
new file mode 100644
@@ -0,0 +1,17 @@
+// { dg-do compile { target { { { i?86-*-* x86_64-*-* } && { ! ia32 } } || { powerpc*-*-* aarch64*-*-* riscv*-*-* } } } }
+// { dg-options "-O2 -fdump-rtl-pro_and_epilogue" }
+// { dg-skip-if "requires hosted libstdc++ for vector" { ! hostedlib } }
+
+// PR rtl-optimization/118502
+
+// The shrink-wrapping should happen around the slow path of vector<int>::push_back,
+// The fast path is just checking if there is enough space and doing a few stores.
+// We want to verify that shrink wrapping always happens.
+
+#include <vector>
+
+void push_back(std::vector<int>& xs, unsigned char x) {
+ xs.push_back(x);
+}
+
+/* { dg-final { scan-rtl-dump "Performing shrink-wrapping" "pro_and_epilogue" } } */