[gcc r17-3860] Add testcase for backward threading from never-executed entry edges [PR105679]
Aldy Hernandez
aldyh@gcc.gnu.org
Wed Sep 2 12:55:39 GMT 2026
https://gcc.gnu.org/g:c25dbfc56075ffb8fbe8e1437e15266b9082bbd7
commit r17-3860-gc25dbfc56075ffb8fbe8e1437e15266b9082bbd7
Author: Aldy Hernandez <aldy@quesejoda.com>
Date: Tue Sep 1 20:44:26 2026 +0000
Add testcase for backward threading from never-executed entry edges [PR105679]
r13-1891-g49ba4fdeb648c1 made the backward threader reject paths
whose entry edge is probably never executed, but landed without a
testcase. Add one retroactively.
[Also AI generated.]
Assisted-by: Claude Fable 5 (Anthropic)
gcc/testsuite/ChangeLog:
PR tree-optimization/105679
PR tree-optimization/126906
* gcc.dg/tree-ssa/pr105679.c: New test.
Diff:
---
gcc/testsuite/gcc.dg/tree-ssa/pr105679.c | 33 ++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr105679.c b/gcc/testsuite/gcc.dg/tree-ssa/pr105679.c
new file mode 100644
index 000000000000..5f7b6cf0d1de
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr105679.c
@@ -0,0 +1,33 @@
+/* PR tree-optimization/105679 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Warray-bounds -fno-strict-overflow -fsanitize=shift -fsanitize-coverage=trace-pc -fdump-tree-threadfull1-details" } */
+
+/* Reduced with cvise from attachment 53010: the Linux kernel hit spurious
+ -Warray-bounds warnings with -fsanitize=shift. The sanitizer's
+ shift-out-of-bounds check for 1 << irq gives the irq > 31 branch a precise
+ never-executed count; the backward threader nevertheless used that block as
+ a thread entry, isolating a never-executed path on which irq > 31 indexes
+ the 2-element array and drawing the bogus warning. The bare shift statement
+ only exists to feed the sanitizer.
+
+ r13-1891 (the PR105679 fix) rejects paths whose entry edge is probably never
+ executed. This test FAILs before that commit and PASSes with it. */
+
+struct many_objects
+{
+ int array[2];
+} instance;
+
+int entry;
+
+int
+work (unsigned int irq)
+{
+ 1 << irq;
+ entry = instance.array[irq]; /* { dg-bogus "above array bounds" } */
+ if (irq)
+ return 0;
+ return 1;
+}
+
+/* { dg-final { scan-tree-dump "path entry is probably never executed" "threadfull1" } } */
More information about the Gcc-cvs
mailing list