[llvm] [RISCV][TTI] Scale the cost of ArithmeticInstr with LMUL (PR #89170)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 22 11:23:26 PDT 2024


================
@@ -1612,29 +1612,56 @@ InstructionCost RISCVTTIImpl::getArithmeticInstrCost(
   if (Op2Info.isConstant())
     ConstantMatCost += getConstantMatCost(1, Op2Info);
 
+  // Assuming instructions falling through the switch-cases have the same cost
+  // until a need arises to differentiate them.
+  unsigned Op;
   switch (TLI->InstructionOpcodeToISD(Opcode)) {
   case ISD::ADD:
   case ISD::SUB:
-  case ISD::AND:
-  case ISD::OR:
-  case ISD::XOR:
+    Op = RISCV::VADD_VV;
+    break;
   case ISD::SHL:
   case ISD::SRL:
   case ISD::SRA:
+    Op = RISCV::VSLL_VV;
+    break;
+  case ISD::AND:
+  case ISD::OR:
+  case ISD::XOR:
+    Op = (Ty->getScalarSizeInBits() == 1) ? RISCV::VMAND_MM : RISCV::VAND_VV;
+    break;
   case ISD::MUL:
   case ISD::MULHS:
   case ISD::MULHU:
+    Op = RISCV::VMUL_VV;
+    break;
+  case ISD::SDIV:
+  case ISD::UDIV:
+    Op = RISCV::VDIV_VV;
+    break;
+  case ISD::SREM:
+  case ISD::UREM:
+    Op = RISCV::VREM_VV;
+    break;
   case ISD::FADD:
   case ISD::FSUB:
   case ISD::FMUL:
----------------
topperc wrote:

It's weird that FMUL uses VFADD.

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


More information about the llvm-commits mailing list