aboutsummaryrefslogtreecommitdiff
path: root/gcc/gcov-tool.cc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2023-11-16 08:33:18 +0100
committerJakub Jelinek <jakub@redhat.com>2023-11-16 08:33:18 +0100
commitf158bd511df1f55ebbbc0df3dee52c4400291984 (patch)
treec865508116fe791732fc2d4ebb9204b229205431 /gcc/gcov-tool.cc
parent9f35d8cd767155e9c24f5ef0944168711d38bc6b (diff)
downloadgcc-f158bd511df1f55ebbbc0df3dee52c4400291984.zip
gcc-f158bd511df1f55ebbbc0df3dee52c4400291984.tar.gz
gcc-f158bd511df1f55ebbbc0df3dee52c4400291984.tar.bz2
i386: Fix mov imm,%rax; mov %rdi,%rdx; mulx %rax -> mov imm,%rdx; mulx %rdi peephole2 [PR112526]
The following testcase is miscompiled on x86_64 since PR110551 r14-4968 commit. That commit added 2 peephole2s, one for mov imm,%rXX; mov %rYY,%rax; mulq %rXX -> mov imm,%rax; mulq %rYY which I believe is ok, and another one for mov imm,%rXX; mov %rYY,%rdx; mulx %rXX, %rZZ, %rWW -> mov imm,%rdx; mulx %rYY, %rZZ, %rWW which is wrong. Both peephole2s verify that %rXX above is dead at the end of the pattern, by checking if %rXX is either one of the registers overwritten in the multiplication (%rdx:%rax in the first case, the 2 destination registers of mulx in the latter case), because we no longer set %rXX to that immediate (we set %rax resp. %rdx to it instead) when the peephole2 replaces it. But, we also need to ensure that the other register previously set to the value of %rYY and newly to imm isn't used after the multiplication, and neither of the peephole2s does that. Now, for the first one (at least assuming in the % pattern the matching operand (i.e. hardcoded %rax resp. %rdx) after RA will always go first) I think it is always the case, because operands[2] if it must be %rax register will be overwritten by mulq writing to %rdx:%rax. But in the second case, there is no reason why %rdx couldn't be used after the pattern, and if it is (like in the testcase), we can't make those changes. So, the patch checks similarly to operands[0] that operands[2] (which ought to be %rdx if RA puts the % match_dup operand first and nothing swaps it afterwards) is either the same register as one of the destination registers of mulx or dies at the end of the multiplication. 2023-11-16 Jakub Jelinek <jakub@redhat.com> PR target/112526 * config/i386/i386.md (mov imm,%rax; mov %rdi,%rdx; mulx %rax -> mov imm,%rdx; mulx %rdi): Verify in define_peephole2 that operands[2] dies or is overwritten at the end of multiplication. * gcc.target/i386/bmi2-pr112526.c: New test.
Diffstat (limited to 'gcc/gcov-tool.cc')
0 files changed, 0 insertions, 0 deletions