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)
commit8c13e3680d3f4fc88830c402a2bcf929db0de9dd
tree26687837bdd765f0eb81a1c96076c7f2e3dbe61a
parent203f09223bb0bed16194d6a28431ba6a2fd5346a
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

llvm-svn: 243361
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Target/X86/X86InstrInfo.cpp
llvm/lib/Target/X86/X86InstrSSE.td
llvm/test/CodeGen/X86/pr2656.ll
llvm/test/CodeGen/X86/sse-fcopysign.ll
llvm/test/CodeGen/X86/vec_fabs.ll