[SDAG][x86] check for relaxed math when matching an FP reduction
authorSanjay Patel <spatel@rotateright.com>
Thu, 15 Aug 2019 12:43:15 +0000 (12:43 +0000)
committerSanjay Patel <spatel@rotateright.com>
Thu, 15 Aug 2019 12:43:15 +0000 (12:43 +0000)
commit57d459309dbbf252dfee7d235f9b17936abca3ad
treeda0abd02f3011bfd198d6fe0ae4b4157504458d7
parent7aa0dbb664ea05e233c503c009052f8682fc0f62
[SDAG][x86] check for relaxed math when matching an FP reduction

If the last step in an FP add reduction allows reassociation and doesn't care
about -0.0, then we are free to recognize that computation as a reduction
that may reorder the intermediate steps.

This is requested directly by PR42705:
https://bugs.llvm.org/show_bug.cgi?id=42705
and solves PR42947 (if horizontal math instructions are actually faster than
the alternative):
https://bugs.llvm.org/show_bug.cgi?id=42947

Differential Revision: https://reviews.llvm.org/D66236

llvm-svn: 368995
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/haddsub.ll
llvm/test/CodeGen/X86/vector-reduce-fadd-fast.ll