[PATCH] D81635: [NFCI][CostModel] Unify FNeg cost

Sam Parker via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 11 02:26:09 PDT 2020


samparker created this revision.
samparker added reviewers: dfukalov, arsenm, RKSimon, spatel.
Herald added subscribers: kerbowa, hiraditya, tpr, nhaehnle, wdng, jvesely.
Herald added a project: LLVM.

Enable TTIImpl::getUserCost to handle FNeg so that getInstructionThroughput can call that instead. This means we can remove the code in the AMDGPU backend too.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81635

Files:
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/lib/Analysis/TargetTransformInfo.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp


Index: llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
@@ -999,10 +999,6 @@
       Idx = CI->getZExtValue();
     return getVectorInstrCost(I->getOpcode(), I->getOperand(0)->getType(), Idx);
   }
-  case Instruction::FNeg:
-    return getArithmeticInstrCost(I->getOpcode(), I->getType(), CostKind,
-                                  TTI::OK_AnyValue, TTI::OK_AnyValue,
-                                  TTI::OP_None, TTI::OP_None, Operands, I);
   default:
     break;
   }
Index: llvm/lib/Analysis/TargetTransformInfo.cpp
===================================================================
--- llvm/lib/Analysis/TargetTransformInfo.cpp
+++ llvm/lib/Analysis/TargetTransformInfo.cpp
@@ -1276,18 +1276,8 @@
   case Instruction::And:
   case Instruction::Or:
   case Instruction::Xor:
+  case Instruction::FNeg:
     return getUserCost(I, CostKind);
-  case Instruction::FNeg: {
-    TargetTransformInfo::OperandValueKind Op1VK, Op2VK;
-    TargetTransformInfo::OperandValueProperties Op1VP, Op2VP;
-    Op1VK = getOperandInfo(I->getOperand(0), Op1VP);
-    Op2VK = OK_AnyValue;
-    Op2VP = OP_None;
-    SmallVector<const Value *, 2> Operands(I->operand_values());
-    return getArithmeticInstrCost(I->getOpcode(), I->getType(), CostKind,
-                                  Op1VK, Op2VK,
-                                  Op1VP, Op2VP, Operands, I);
-  }
   case Instruction::Select:
   case Instruction::ICmp:
   case Instruction::FCmp:
Index: llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
===================================================================
--- llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -861,11 +861,14 @@
     case Instruction::AShr:
     case Instruction::And:
     case Instruction::Or:
-    case Instruction::Xor: {
-      TargetTransformInfo::OperandValueKind Op1VK, Op2VK;
-      TargetTransformInfo::OperandValueProperties Op1VP, Op2VP;
-      Op1VK = TTI::getOperandInfo(U->getOperand(0), Op1VP);
-      Op2VK = TTI::getOperandInfo(U->getOperand(1), Op2VP);
+    case Instruction::Xor:
+    case Instruction::FNeg: {
+      TTI::OperandValueProperties Op1VP = TTI::OP_None;
+      TTI::OperandValueProperties Op2VP = TTI::OP_None;
+      TTI::OperandValueKind Op1VK =
+        TTI::getOperandInfo(U->getOperand(0), Op1VP);
+      TTI::OperandValueKind Op2VK = Opcode != Instruction::FNeg ?
+        TTI::getOperandInfo(U->getOperand(1), Op2VP) : TTI::OK_AnyValue;
       SmallVector<const Value *, 2> Operands(U->operand_values());
       return TargetTTI->getArithmeticInstrCost(Opcode, Ty, CostKind,
                                                Op1VK, Op2VK,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81635.270065.patch
Type: text/x-patch
Size: 2858 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200611/deaa12d2/attachment-0001.bin>


More information about the llvm-commits mailing list