https://gcc.gnu.org/g:fe89c51bc6b94fd6aa95f5ffbabc6a0f40274798
commit r17-4025-gfe89c51bc6b94fd6aa95f5ffbabc6a0f40274798 Author: Aldy Hernandez <[email protected]> Date: Tue Sep 8 11:20:03 2026 +0000 testsuite: cover adjust_paths_after_duplication [The test is AI generated, because seriously, who wants to go back in time to add tests for old threading patches. ;-)]] The adjust_paths_after_duplication function is a hotspot for the threaders in general. It has been for quite a while, but despite my desire to nuke it, in part because I'm embarassed to have written it, others have expressed interest in keeping it because it catches real things. The code is ugly, fragile, and I'm afraid to touch it without a proper testcase. This adds the missing testcase. In follow-up patches I'll do some surgery in this abomination of a function. Assisted-by: Claude Opus 5 gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/ssa-thread-27.c: New test. Diff: --- gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-27.c | 33 +++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-27.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-27.c new file mode 100644 index 000000000000..8fe595f56056 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-27.c @@ -0,0 +1,33 @@ +/* Cover adjust_paths_after_duplication, which had no test. Threading + the path out of "t == 1" leaves two registered candidates starting on + the edge it started on: one shares a prefix with it and is rewired + onto the copies, the other is entirely a prefix of it and is dropped. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-threadfull1-details" } */ + +int g; +void bar (void); + +void +f (int a, int b) +{ + int t = 0; + if (a > 0) + t = 1; + if (b > 0) + t += 2; + if (t == 1) + bar (); + if (t == 3) + bar (); + if (t == 0) + bar (); + g = t; +} + +/* Both candidates are considered. */ +/* { dg-final { scan-tree-dump-times "adjusting candidate" 2 "threadfull1" } } */ +/* One of them keeps a tail and is rewired onto the copied blocks. */ +/* { dg-final { scan-tree-dump "adjusted candidate" "threadfull1" } } */ +/* The other has nothing left once the shared prefix goes. */ +/* { dg-final { scan-tree-dump "Adjusted candidate is EMPTY" "threadfull1" } } */
