[X86] Combine (cmov (and/or (setcc) (setcc))) into (cmov (cmov)).
authorAhmed Bougacha <ahmed.bougacha@gmail.com>
Tue, 3 Mar 2015 01:09:14 +0000 (01:09 +0000)
committerAhmed Bougacha <ahmed.bougacha@gmail.com>
Tue, 3 Mar 2015 01:09:14 +0000 (01:09 +0000)
commit8b5527deefdfcb7a2ea90b9b4d2116864e7d493f
treeb551209682f7aeebebd018b58211a509a74554d1
parenta8182029a126d9b8dcb3171b23f1c5d63f5ca1fc
[X86] Combine (cmov (and/or (setcc) (setcc))) into (cmov (cmov)).

Fold and/or of setcc's to double CMOV:

(CMOV F, T, ((cc1 | cc2) != 0)) -> (CMOV (CMOV F, T, cc1), T, cc2)
(CMOV F, T, ((cc1 & cc2) != 0)) -> (CMOV (CMOV T, F, !cc1), F, !cc2)

When we can't use the CMOV instruction, it might increase branch
mispredicts.  When we can, or when there is no mispredict, this
improves throughput and reduces register pressure.

These can't be catched by generic combines, because the pattern can
appear when legalizing some instructions (such as fcmp une).

rdar://19767934
http://reviews.llvm.org/D7634

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231045 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/cmovcmov.ll [new file with mode: 0644]
test/CodeGen/X86/fast-isel-select-cmov2.ll