fix invalid load folding with SSE/AVX FP logical instructions (PR22371)
authorSanjay Patel <spatel@rotateright.com>
Tue, 28 Jul 2015 00:48:32 +0000 (00:48 +0000)
committerSanjay Patel <spatel@rotateright.com>
Tue, 28 Jul 2015 00:48:32 +0000 (00:48 +0000)
commit3d89ab8299eeecacf3c51b135190ce91057263cc
tree4fd051d8857545f635656f093272bb900d4262b9
parentf7681b3e3a302b22d728cb4e59fbaade350b635f
fix invalid load folding with SSE/AVX FP logical instructions (PR22371)

This is a follow-up to the FIXME that was added with D7474 ( http://reviews.llvm.org/rL229531 ).
I thought this load folding bug had been made hard-to-hit, but it turns out to be very easy
when targeting 32-bit x86 and causes a miscompile/crash in Wine:
https://bugs.winehq.org/show_bug.cgi?id=38826
https://llvm.org/bugs/show_bug.cgi?id=22371#c25

The quick fix is to simply remove the scalar FP logical instructions from the load folding table
in X86InstrInfo, but that causes us to miss load folds that should be possible when lowering fabs,
fneg, fcopysign. So the majority of this patch is altering those lowerings to use *vector* FP
logical instructions (because that's all x86 gives us anyway). That lets us do the load folding
legally.

Differential Revision: http://reviews.llvm.org/D11477

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243361 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/X86/X86ISelLowering.cpp
lib/Target/X86/X86InstrInfo.cpp
lib/Target/X86/X86InstrSSE.td
test/CodeGen/X86/pr2656.ll
test/CodeGen/X86/sse-fcopysign.ll
test/CodeGen/X86/vec_fabs.ll