X86: Bad peephole interaction between adc, MOV32r0
authorDavid Majnemer <david.majnemer@gmail.com>
Sat, 18 May 2013 01:02:03 +0000 (01:02 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Sat, 18 May 2013 01:02:03 +0000 (01:02 +0000)
commit8a55c2ecd4d7648a6564091d428e18ec2146ff8e
tree20f6df4c43b569d628fc4eb455d6cf867e89d91b
parent24623dcd249939cfa35af4771b61aa47a5cbffc8
X86: Bad peephole interaction between adc, MOV32r0

The peephole tries to reorder MOV32r0 instructions such that they are
before the instruction that modifies EFLAGS.

The problem is that the peephole does not consider the case where the
instruction that modifies EFLAGS also depends on the previous state of
EFLAGS.

Instead, walk backwards until we find an instruction that has a def for
EFLAGS but does not have a use.
If we find such an instruction, insert the MOV32r0 before it.
If it cannot find such an instruction, skip the optimization.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182184 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/X86/X86InstrInfo.cpp
test/CodeGen/X86/pr16031.ll [new file with mode: 0644]