]> gcc.gnu.org Git - gcc.git/commit
i386: Avoid mutual recursion between two peephole2s [PR99600]
authorJakub Jelinek <jakub@redhat.com>
Tue, 16 Mar 2021 17:46:20 +0000 (18:46 +0100)
committerJakub Jelinek <jakub@redhat.com>
Tue, 16 Mar 2021 17:46:20 +0000 (18:46 +0100)
commitd55ce33a34a8e33d17285228b32cf1e564241a70
tree7ffa1a7aac0ba612b27ff61e4482ac3c78aa87d1
parent1c7bec8bfbc5457c1b57d0e3b67f5d6bc8812e57
i386: Avoid mutual recursion between two peephole2s [PR99600]

As the testcase shows, the compiler hangs and eats all memory when compiling
it.  This is because in r11-7274-gdecd8fb0128870d0d768ba53dae626913d6d9c54
I have changed the ix86_avoid_lea_for_addr splitting from a splitter
into a peephole2 (because during splitting passes we don't have guaranteed
df, while during peephole2 we do).
The problem is we have another peephole2 that works in the opposite way,
when seeing split lea (in particular ASHIFT followed by PLUS) it attempts
to turn it back into a lea.
In the past, they were fighting against each other, but as they were in
different passes, simply the last one won.  So, split after reload
split the lea into shift left and plus, peephole2 reverted that (but, note
not perfectly, the peephole2 doesn't understand that something can be placed
into lea disp; to be fixed for GCC12) and then another split pass split the
lea appart again.
But my changes and the way peephole2 works means that we endlessly iterate
over those two, the first peephole2 splits the lea, the second one reverts
it, the first peephole2 splits the new lea back into new 2 insns and so
forth forever.
So, we need to break the cycle somehow.  This patch does that by not emitting
an ASHIFT insn from ix86_split_lea_for_addr but emitting a corresponding
MULT by constant instead, and splitting that later back into ASHIFT.

2021-03-16  Jakub Jelinek  <jakub@redhat.com>

PR target/99600
* config/i386/i386-expand.c (ix86_split_lea_for_addr): Emit a MULT
rather than ASHIFT.
* config/i386/i386.md (mult by 1248 into ashift): New splitter.

* gcc.target/i386/pr99600.c: New test.
gcc/config/i386/i386-expand.c
gcc/config/i386/i386.md
gcc/testsuite/gcc.target/i386/pr99600.c [new file with mode: 0644]
This page took 0.066832 seconds and 5 git commands to generate.