diff options
| author | Sam Clegg <sbc@chromium.org> | 2018-10-09 18:41:17 +0000 |
|---|---|---|
| committer | Sam Clegg <sbc@chromium.org> | 2018-10-09 18:41:17 +0000 |
| commit | 81abca32fba4d8eb537c4ac4445e0175309b9fc8 (patch) | |
| tree | 741e6bbd64aa9c82fdf95fceed216ed280218d51 | |
| parent | a9ea9c5034ddca7ccd5285b34a3d1c2772b12862 (diff) | |
| download | bcm5719-llvm-81abca32fba4d8eb537c4ac4445e0175309b9fc8.tar.gz bcm5719-llvm-81abca32fba4d8eb537c4ac4445e0175309b9fc8.zip | |
[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
| -rw-r--r-- | llvm/include/llvm/CodeGen/BasicTTIImpl.h | 3 | ||||
| -rw-r--r-- | llvm/test/Transforms/SLPVectorizer/X86/fabs-cost-softfp.ll | 29 |
2 files changed, 31 insertions, 1 deletions
diff --git a/llvm/include/llvm/CodeGen/BasicTTIImpl.h b/llvm/include/llvm/CodeGen/BasicTTIImpl.h index 0cb1ab62785..b460cdc0ba1 100644 --- a/llvm/include/llvm/CodeGen/BasicTTIImpl.h +++ b/llvm/include/llvm/CodeGen/BasicTTIImpl.h @@ -1139,7 +1139,8 @@ public: SmallVector<unsigned, 2> CustomCost; for (unsigned ISD : ISDs) { if (TLI->isOperationLegalOrPromote(ISD, LT.second)) { - if (IID == Intrinsic::fabs && TLI->isFAbsFree(LT.second)) { + if (IID == Intrinsic::fabs && LT.second.isFloatingPoint() && + TLI->isFAbsFree(LT.second)) { return 0; } diff --git a/llvm/test/Transforms/SLPVectorizer/X86/fabs-cost-softfp.ll b/llvm/test/Transforms/SLPVectorizer/X86/fabs-cost-softfp.ll new file mode 100644 index 00000000000..add4858b7c5 --- /dev/null +++ b/llvm/test/Transforms/SLPVectorizer/X86/fabs-cost-softfp.ll @@ -0,0 +1,29 @@ +; Regression test from https://bugs.llvm.org/show_bug.cgi?id=39168 +; Based on code from `compiler-rt/lib/builtins/multc3.c` +; On plaforms where fp128 lowers to an interger type (soft-fp) we +; shouldn't be calling isFAbsFree() on the legalized type. + +; RUN: opt -slp-vectorizer -slp-threshold=-10 -S %s | FileCheck %s +; CHECK: call <2 x fp128> @llvm.fabs.v2f128(<2 x fp128 + +target triple = "i686-unknown-linux-gnu" + +define void @vectorize_fp128(fp128 %c, fp128 %d) #0 { +entry: + %0 = tail call fp128 @llvm.fabs.f128(fp128 %c) + %cmpinf10 = fcmp oeq fp128 %0, 0xL00000000000000007FFF000000000000 + %1 = tail call fp128 @llvm.fabs.f128(fp128 %d) + %cmpinf12 = fcmp oeq fp128 %1, 0xL00000000000000007FFF000000000000 + %or.cond39 = or i1 %cmpinf10, %cmpinf12 + br i1 %or.cond39, label %if.then13, label %if.end24 + +if.then13: ; preds = %entry + unreachable + +if.end24: ; preds = %entry + ret void +} + +declare fp128 @llvm.fabs.f128(fp128) + +attributes #0 = { "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" } |

