[llvm] [LV][AArch64] LoopVectorizer allows scalable frem instructions (PR #76247)

Maciej Gabka via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 11 01:59:10 PST 2024


================
@@ -6951,10 +6951,26 @@ LoopVectorizationCostModel::getInstructionCost(Instruction *I, ElementCount VF,
       Op2Info.Kind = TargetTransformInfo::OK_UniformValue;
 
     SmallVector<const Value *, 4> Operands(I->operand_values());
-    return TTI.getArithmeticInstrCost(
+    auto InstrCost = TTI.getArithmeticInstrCost(
         I->getOpcode(), VectorTy, CostKind,
         {TargetTransformInfo::OK_AnyValue, TargetTransformInfo::OP_None},
         Op2Info, Operands, I);
+
+    // Some targets replace frem with vector library calls.
+    if (I->getOpcode() == Instruction::FRem) {
+      LibFunc Func;
+      if (TLI->getLibFunc(I->getOpcode(), I->getType(), Func)) {
+        if (TLI->isFunctionVectorizable(TLI->getName(Func))) {
----------------
mgabka wrote:

I think you could just combine this condition with the one above to avoid excessive indentation.

https://github.com/llvm/llvm-project/pull/76247


More information about the llvm-commits mailing list