[PATCH] D52899: [TTI] Check that lowered type is floating point before calling isFabsFree

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 9 11:43:57 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL344069: [SLPVectorizer] Check that lowered type is floating point before calling… (authored by sbc, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D52899

Files:
  llvm/trunk/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/trunk/test/Transforms/SLPVectorizer/X86/fabs-cost-softfp.ll


Index: llvm/trunk/include/llvm/CodeGen/BasicTTIImpl.h
===================================================================
--- llvm/trunk/include/llvm/CodeGen/BasicTTIImpl.h
+++ llvm/trunk/include/llvm/CodeGen/BasicTTIImpl.h
@@ -1139,7 +1139,8 @@
     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;
         }
 
Index: llvm/trunk/test/Transforms/SLPVectorizer/X86/fabs-cost-softfp.ll
===================================================================
--- llvm/trunk/test/Transforms/SLPVectorizer/X86/fabs-cost-softfp.ll
+++ llvm/trunk/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" }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52899.168843.patch
Type: text/x-patch
Size: 1999 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181009/790fb5aa/attachment.bin>


More information about the llvm-commits mailing list