================
@@ -8362,9 +8362,20 @@ BoUpSLP::getEntryCost(const TreeEntry *E, ArrayRef<Value 
*> VectorizedVals,
       unsigned OpIdx = isa<UnaryOperator>(VL0) ? 0 : 1;
       TTI::OperandValueInfo Op1Info = getOperandInfo(E->getOperand(0));
       TTI::OperandValueInfo Op2Info = getOperandInfo(E->getOperand(OpIdx));
-      return TTI->getArithmeticInstrCost(ShuffleOrOp, VecTy, CostKind, Op1Info,
-                                         Op2Info) +
-             CommonCost;
+      auto VecCost = TTI->getArithmeticInstrCost(ShuffleOrOp, VecTy, CostKind,
+                                                 Op1Info, Op2Info);
+      // Some targets can replace frem with vector library calls.
+      if (ShuffleOrOp == Instruction::FRem) {
+        LibFunc Func;
+        if (TLI->getLibFunc(ShuffleOrOp, ScalarTy, Func) &&
+            TLI->isFunctionVectorizable(TLI->getName(Func),
+                                        VecTy->getElementCount())) {
----------------
paschalis-mpeis wrote:

I'd rather not adapt `TTI.getArithmeticInstrCost` API, as that would cause 
changes in 150+ places, including every target that overrides that. But I 
understand your concern as this is specific, affecting one of our instructions.

TLI is simply passed to `getVecLibCallCost`, just like it's widely passed 
around in other places in the SLP code. This isn't making the code any target 
dependent, TLI/TTI are abstractions to that.

Internally, `getVecLibCallCost` does those checks, which have now moved to 
`VectorUtils`.
SLP gets a valid cost if there's one, and picks the minimum between the two.

https://github.com/llvm/llvm-project/pull/82488
_______________________________________________
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to