[PATCH] D128172: [SLP] Add cost model for `llvm.powi.*` intrinsics

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 23 05:42:13 PDT 2022


dmgreen added a comment.

Thanks. I guess that changes all the negative constant values too..

If you want a cost for negative numbers I think it would use the abs of the value in the ActiveBits+PopCount-2 computation, plus the div like you already have it.



================
Comment at: llvm/include/llvm/CodeGen/BasicTTIImpl.h:1426
+          unsigned PopCount =
+              countPopulation((unsigned int)RHSC->getSExtValue());
+          InstructionCost Cost = (ActiveBits + PopCount - 2) *
----------------
I think it can go via an APInt: RHSC->getValue().countPopulation()


================
Comment at: llvm/include/llvm/CodeGen/BasicTTIImpl.h:1430
+                                     Instruction::FMul, RetTy, CostKind);
+          if (RHSC->getSExtValue() < 0)
+            Cost += thisT()->getArithmeticInstrCost(Instruction::FDiv, RetTy,
----------------
For negative numbers if looks like it should use ((-RHSC).ActiveBits + (-RHSC).PopCount - 2)) * Mul + Div, using the negative -RHSC in the calculations above.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128172/new/

https://reviews.llvm.org/D128172



More information about the llvm-commits mailing list