[llvm] [SystemZ] i128 cost model (PR #78528)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 17 17:16:38 PST 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff add189cdf01e92ca30687291a98e936b7706ee38 4b80902a18d5467412a7580f096fc8929e8fe98e -- llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.h
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp b/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp
index d69ff9e96c..d144de9abf 100644
--- a/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp
@@ -75,7 +75,8 @@ InstructionCost SystemZTTIImpl::getIntImmCost(const APInt &Imm, Type *Ty,
   // here, so that constant hoisting will ignore this constant.
   if (BitSize == 0)
     return TTI::TCC_Free;
-  // No cost model for operations on integers larger than 128 bit implemented yet.
+  // No cost model for operations on integers larger than 128 bit implemented
+  // yet.
   if ((!ST->hasVector() && BitSize > 64) || BitSize > 128)
     return TTI::TCC_Free;
 
@@ -493,23 +494,21 @@ InstructionCost SystemZTTIImpl::getArithmeticInstrCost(
       if (Opcode == Instruction::Xor) {
         for (const Value *A : Args) {
           if (const Instruction *I = dyn_cast<Instruction>(A))
-            if (I->hasOneUse() &&
-                (I->getOpcode() == Instruction::Or ||
-                 I->getOpcode() == Instruction::And ||
-                 I->getOpcode() == Instruction::Xor))
+            if (I->hasOneUse() && (I->getOpcode() == Instruction::Or ||
+                                   I->getOpcode() == Instruction::And ||
+                                   I->getOpcode() == Instruction::Xor))
               if ((ScalarBits <= 64 && ST->hasMiscellaneousExtensions3()) ||
-                  (isInt128InVR(Ty) &&
-                   (I->getOpcode() == Instruction::Or || ST->hasVectorEnhancements1())))
+                  (isInt128InVR(Ty) && (I->getOpcode() == Instruction::Or ||
+                                        ST->hasVectorEnhancements1())))
                 return 0 + ImmLoadCost;
         }
-      }
-      else if (Opcode == Instruction::And || Opcode == Instruction::Or) {
+      } else if (Opcode == Instruction::And || Opcode == Instruction::Or) {
         for (const Value *A : Args) {
           if (const Instruction *I = dyn_cast<Instruction>(A))
             if ((I->hasOneUse() && I->getOpcode() == Instruction::Xor) &&
                 ((ScalarBits <= 64 && ST->hasMiscellaneousExtensions3()) ||
-                 (isInt128InVR(Ty) &&
-                  (Opcode == Instruction::And || ST->hasVectorEnhancements1()))))
+                 (isInt128InVR(Ty) && (Opcode == Instruction::And ||
+                                       ST->hasVectorEnhancements1()))))
               return 0 + ImmLoadCost;
         }
       }
@@ -605,7 +604,8 @@ InstructionCost SystemZTTIImpl::getArithmeticInstrCost(
 
   // Fallback to the default implementation.
   return BaseT::getArithmeticInstrCost(Opcode, Ty, CostKind, Op1Info, Op2Info,
-                                       Args, CxtI) + ImmLoadCost;
+                                       Args, CxtI) +
+         ImmLoadCost;
 }
 
 InstructionCost SystemZTTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
@@ -822,8 +822,7 @@ InstructionCost SystemZTTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst,
           // If operands of an fp-type was compared, this costs +1.
           Cost++;
         return Cost;
-      }
-      else if (isInt128InVR(Dst)) {
+      } else if (isInt128InVR(Dst)) {
         // Extensions from GPR to i128 (in VR) typically costs two instructions,
         // but a zero-extending load would be just one extra instruction.
         if (Opcode == Instruction::ZExt && I != nullptr)
@@ -837,7 +836,7 @@ InstructionCost SystemZTTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst,
     if (Opcode == Instruction::Trunc && isInt128InVR(Src) && I != nullptr) {
       if (LoadInst *Ld = dyn_cast<LoadInst>(I->getOperand(0)))
         if (Ld->hasOneUse())
-          return 0;  // Will be converted to GPR load.
+          return 0; // Will be converted to GPR load.
       bool OnlyTruncatingStores = true;
       for (const User *U : I->users())
         if (!isa<StoreInst>(U)) {
diff --git a/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.h b/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.h
index 2cccdf6d17..aa1a8edb83 100644
--- a/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.h
+++ b/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.h
@@ -28,7 +28,9 @@ class SystemZTTIImpl : public BasicTTIImplBase<SystemZTTIImpl> {
 
   unsigned const LIBCALL_COST = 30;
 
-  bool isInt128InVR(Type *Ty) { return Ty->isIntegerTy(128) && ST->hasVector(); }
+  bool isInt128InVR(Type *Ty) {
+    return Ty->isIntegerTy(128) && ST->hasVector();
+  }
 
 public:
   explicit SystemZTTIImpl(const SystemZTargetMachine *TM, const Function &F)

``````````

</details>


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


More information about the llvm-commits mailing list