[x86][DAG] Unroll vectorized FREMs that will become libcalls
commit8b5d9cbbfedc7a91e3b462030e534c5982de674d
authorNabeel Omer <Nabeel.Omer@sony.com>
Tue, 24 May 2022 12:30:47 +0000 (24 13:30 +0100)
committerJeremy Morse <jeremy.morse@sony.com>
Tue, 24 May 2022 12:34:51 +0000 (24 13:34 +0100)
tree5e9ab6be925dcba3a415c6deb8931b6b4ada33d5
parent1e2b746390e3c869d34a8651c35e68e26214e410
[x86][DAG] Unroll vectorized FREMs that will become libcalls

Currently, two element vectors produced as the result of a binary op are
widened to four element vectors on x86 by
DAGTypeLegalizer::WidenVecRes_BinaryCanTrap. If the op still isn't legal
after widening it is unrolled into 4 scalar ops in SelectionDAG before
being converted into a libcall. This way we end up with 4 libcalls (two of
them on known undef elements) instead of the original two libcalls.

This patch modifies DAGTypeLegalizer::WidenVectorResult to ensure that if
it is known that a binary op will be tunred into a libcall, it is unrolled
instead of being widened. This prevents the creation of the extra scalar
instructions on known undef elements and (eventually) libacalls with known
undef parameters which would otherwise be created when the op gets expanded
post widening.

Differential Revision: https://reviews.llvm.org/D125988
llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
llvm/test/CodeGen/X86/frem-libcall.ll