[SLPVectorizer] Check that lowered type is floating point before calling isFabsFree
authorSam Clegg <sbc@chromium.org>
Tue, 9 Oct 2018 18:41:17 +0000 (18:41 +0000)
committerSam Clegg <sbc@chromium.org>
Tue, 9 Oct 2018 18:41:17 +0000 (18:41 +0000)
commit81abca32fba4d8eb537c4ac4445e0175309b9fc8
tree741e6bbd64aa9c82fdf95fceed216ed280218d51
parenta9ea9c5034ddca7ccd5285b34a3d1c2772b12862
[SLPVectorizer] Check that lowered type is floating point before calling isFabsFree

In the case of soft-fp (e.g. fp128 under wasm) the result of
getTypeLegalizationCost() can be an integer type even if the input is
floating point (See LegalizeTypeAction::TypeSoftenFloat).

Before calling isFabsFree() (which asserts if given a non-fp
type) we need to check that that result is fp.  This is safe since in
fabs is certainly not free in the soft-fp case.

Fixes PR39168

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

llvm-svn: 344069
llvm/include/llvm/CodeGen/BasicTTIImpl.h
llvm/test/Transforms/SLPVectorizer/X86/fabs-cost-softfp.ll [new file with mode: 0644]