[SLP] match maxnum/minnum intrinsics as FP reduction ops
authorSanjay Patel <spatel@rotateright.com>
Mon, 18 Jan 2021 21:18:57 +0000 (16:18 -0500)
committerSanjay Patel <spatel@rotateright.com>
Mon, 18 Jan 2021 22:37:16 +0000 (17:37 -0500)
commit5b77ac32b1150d066b35b45d6d982f4b4a1f62ff
tree3b1143d543d96eedd694de638f583bbca8e63e7e
parent1c31459153647a21da9b5cdbb01f78bccfb341a5
[SLP] match maxnum/minnum intrinsics as FP reduction ops

After much refactoring over the last 2 weeks to the reduction
matching code, I think this change is finally ready.

We effectively broke fmax/fmin vector reduction optimization
when we started canonicalizing to intrinsics in instcombine,
so this should restore that functionality for SLP.

There are still FMF problems here as noted in the code comments,
but we should be avoiding miscompiles on those for fmax/fmin by
restricting to full 'fast' ops (negative tests are included).

Fixing FMF propagation is a planned follow-up.

Differential Revision: https://reviews.llvm.org/D94913
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/test/Transforms/PhaseOrdering/X86/vector-reductions-expanded.ll
llvm/test/Transforms/SLPVectorizer/X86/fmaxnum.ll
llvm/test/Transforms/SLPVectorizer/X86/fminnum.ll