Skip to content

Commit 81abca3

Browse files
committedOct 9, 2018
[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
1 parent a9ea9c5 commit 81abca3

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed
 

‎llvm/include/llvm/CodeGen/BasicTTIImpl.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,8 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
11391139
SmallVector<unsigned, 2> CustomCost;
11401140
for (unsigned ISD : ISDs) {
11411141
if (TLI->isOperationLegalOrPromote(ISD, LT.second)) {
1142-
if (IID == Intrinsic::fabs && TLI->isFAbsFree(LT.second)) {
1142+
if (IID == Intrinsic::fabs && LT.second.isFloatingPoint() &&
1143+
TLI->isFAbsFree(LT.second)) {
11431144
return 0;
11441145
}
11451146

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
; Regression test from https://bugs.llvm.org/show_bug.cgi?id=39168
2+
; Based on code from `compiler-rt/lib/builtins/multc3.c`
3+
; On plaforms where fp128 lowers to an interger type (soft-fp) we
4+
; shouldn't be calling isFAbsFree() on the legalized type.
5+
6+
; RUN: opt -slp-vectorizer -slp-threshold=-10 -S %s | FileCheck %s
7+
; CHECK: call <2 x fp128> @llvm.fabs.v2f128(<2 x fp128
8+
9+
target triple = "i686-unknown-linux-gnu"
10+
11+
define void @vectorize_fp128(fp128 %c, fp128 %d) #0 {
12+
entry:
13+
%0 = tail call fp128 @llvm.fabs.f128(fp128 %c)
14+
%cmpinf10 = fcmp oeq fp128 %0, 0xL00000000000000007FFF000000000000
15+
%1 = tail call fp128 @llvm.fabs.f128(fp128 %d)
16+
%cmpinf12 = fcmp oeq fp128 %1, 0xL00000000000000007FFF000000000000
17+
%or.cond39 = or i1 %cmpinf10, %cmpinf12
18+
br i1 %or.cond39, label %if.then13, label %if.end24
19+
20+
if.then13: ; preds = %entry
21+
unreachable
22+
23+
if.end24: ; preds = %entry
24+
ret void
25+
}
26+
27+
declare fp128 @llvm.fabs.f128(fp128)
28+
29+
attributes #0 = { "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" }

0 commit comments

Comments
 (0)
Please sign in to comment.