[llvm] [AArch64] Consider negated powers of 2 when calculating throughput cost (PR #143013)
    David Green via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Tue Jun 10 05:58:16 PDT 2025
    
    
  
================
@@ -4005,25 +4005,34 @@ InstructionCost AArch64TTIImpl::getArithmeticInstrCost(
       // have similar cost.
       auto VT = TLI->getValueType(DL, Ty);
       if (VT.isScalarInteger() && VT.getSizeInBits() <= 64) {
-        if (Op2Info.isPowerOf2()) {
+        if (Op2Info.isPowerOf2() || Op2Info.isNegatedPowerOf2()) {
+          // Neg can be folded into the asr instruction.
+          // FIXME: Is the throughput cost of asr + neg the same as just asr?
----------------
davemgreen wrote:
You can remove this FIXME I think. It will just mean that the cost of scalar is a little lower than vector. Or make it part of the note above, that we are assuming that the neg and the neg+asr share the same cost.
https://github.com/llvm/llvm-project/pull/143013
    
    
More information about the llvm-commits
mailing list