Skip to content

[LLVM] Rename Type::getTruncatedType() and Type::getExtendedType()#196528

Closed
jurahul wants to merge 1 commit into
llvm:mainfrom
jurahul:nfc_rename_getTruncated
Closed

[LLVM] Rename Type::getTruncatedType() and Type::getExtendedType()#196528
jurahul wants to merge 1 commit into
llvm:mainfrom
jurahul:nfc_rename_getTruncated

Conversation

@jurahul
Copy link
Copy Markdown
Contributor

@jurahul jurahul commented May 8, 2026

getTruncatedType and getExtendedType are too generic names, so rename them as follows:

  • getTruncatedType -> getHalfWidthType
  • getExtendedType -> getDoubleWidthType
  • getTruncatedElementVectorType -> getHalfWidthElementVectorType
  • getExtendedElementVectorType -> getDoubleWidthElementVectorType

These new names convey the semantics more precisely.

@jurahul jurahul marked this pull request as ready for review May 8, 2026 16:00
@jurahul jurahul requested a review from nikic as a code owner May 8, 2026 16:00
@jurahul jurahul requested a review from s-barannikov May 8, 2026 16:00
@llvmorg-github-actions llvmorg-github-actions Bot added backend:AArch64 backend:X86 clang:codegen IR generation bugs: mangling, exceptions, etc. vectorizers llvm:instcombine Covers the InstCombine, InstSimplify and AggressiveInstCombine passes llvm:ir llvm:analysis Includes value tracking, cost tables and constant folding llvm:transforms llvm:SandboxIR llvm:vectorcombine labels May 8, 2026
@llvmorg-github-actions
Copy link
Copy Markdown

llvmorg-github-actions Bot commented May 8, 2026

@llvm/pr-subscribers-llvm-transforms
@llvm/pr-subscribers-llvm-ir
@llvm/pr-subscribers-llvm-analysis
@llvm/pr-subscribers-backend-aarch64
@llvm/pr-subscribers-vectorizers

@llvm/pr-subscribers-clang-codegen

Author: Rahul Joshi (jurahul)

Changes

getTruncated and getExtended are too generic names, so rename them as follows:

  • getTruncatedType -> getHalfWidthType
  • getExtendedType -> getDoubleWidthType
  • getTruncatedElementVectorType -> getHalfWidthElementVectorType
  • getExtendedElementVectorType -> getDoubleWidthElementVectorType

These new names convey the semantics more precisely.


Patch is 24.51 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/196528.diff

15 Files Affected:

  • (modified) clang/lib/CodeGen/TargetBuiltins/ARM.cpp (+7-7)
  • (modified) llvm/include/llvm/IR/DerivedTypes.h (+23-21)
  • (modified) llvm/include/llvm/IR/Type.h (+2-2)
  • (modified) llvm/include/llvm/SandboxIR/Type.h (+12-10)
  • (modified) llvm/lib/Analysis/LoopCacheAnalysis.cpp (+1-1)
  • (modified) llvm/lib/IR/Intrinsics.cpp (+4-4)
  • (modified) llvm/lib/SandboxIR/Type.cpp (+5-5)
  • (modified) llvm/lib/Target/AArch64/AArch64ISelLowering.cpp (+1-1)
  • (modified) llvm/lib/Target/X86/X86InstCombineIntrinsic.cpp (+1-1)
  • (modified) llvm/lib/Target/X86/X86TargetTransformInfo.cpp (+1-1)
  • (modified) llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp (+1-1)
  • (modified) llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp (+1-1)
  • (modified) llvm/lib/Transforms/Vectorize/VectorCombine.cpp (+1-1)
  • (modified) llvm/unittests/IR/VectorTypesTest.cpp (+4-4)
  • (modified) llvm/unittests/SandboxIR/TypesTest.cpp (+10-9)
diff --git a/clang/lib/CodeGen/TargetBuiltins/ARM.cpp b/clang/lib/CodeGen/TargetBuiltins/ARM.cpp
index 8bfacc5580bd6..8d237f51ed0b0 100644
--- a/clang/lib/CodeGen/TargetBuiltins/ARM.cpp
+++ b/clang/lib/CodeGen/TargetBuiltins/ARM.cpp
@@ -1256,7 +1256,7 @@ Value *CodeGenFunction::EmitCommonNeonBuiltinExpr(
   }
   case NEON::BI__builtin_neon_vaddhn_v: {
     llvm::FixedVectorType *SrcTy =
-        llvm::FixedVectorType::getExtendedElementVectorType(VTy);
+        llvm::FixedVectorType::getDoubleWidthElementVectorType(VTy);
 
     // %sum = add <4 x i32> %lhs, %rhs
     Ops[0] = Builder.CreateBitCast(Ops[0], SrcTy);
@@ -1455,7 +1455,7 @@ Value *CodeGenFunction::EmitCommonNeonBuiltinExpr(
     return EmitNeonCall(CGM.getIntrinsic(LLVMIntrinsic, Tys), Ops, NameHint);
   }
   case NEON::BI__builtin_neon_vcvtx_f32_v: {
-    llvm::Type *Tys[2] = { VTy->getTruncatedElementVectorType(VTy), Ty};
+    llvm::Type *Tys[2] = {VTy->getHalfWidthElementVectorType(VTy), Ty};
     return EmitNeonCall(CGM.getIntrinsic(LLVMIntrinsic, Tys), Ops, NameHint);
 
   }
@@ -1541,7 +1541,7 @@ Value *CodeGenFunction::EmitCommonNeonBuiltinExpr(
   }
   case NEON::BI__builtin_neon_vmovl_v: {
     llvm::FixedVectorType *DTy =
-        llvm::FixedVectorType::getTruncatedElementVectorType(VTy);
+        llvm::FixedVectorType::getHalfWidthElementVectorType(VTy);
     Ops[0] = Builder.CreateBitCast(Ops[0], DTy);
     if (Usgn)
       return Builder.CreateZExt(Ops[0], Ty, "vmovl");
@@ -1549,7 +1549,7 @@ Value *CodeGenFunction::EmitCommonNeonBuiltinExpr(
   }
   case NEON::BI__builtin_neon_vmovn_v: {
     llvm::FixedVectorType *QTy =
-        llvm::FixedVectorType::getExtendedElementVectorType(VTy);
+        llvm::FixedVectorType::getDoubleWidthElementVectorType(VTy);
     Ops[0] = Builder.CreateBitCast(Ops[0], QTy);
     return Builder.CreateTrunc(Ops[0], Ty, "vmovn");
   }
@@ -1652,7 +1652,7 @@ Value *CodeGenFunction::EmitCommonNeonBuiltinExpr(
                              "vshl_n");
   case NEON::BI__builtin_neon_vshll_n_v: {
     llvm::FixedVectorType *SrcTy =
-        llvm::FixedVectorType::getTruncatedElementVectorType(VTy);
+        llvm::FixedVectorType::getHalfWidthElementVectorType(VTy);
     Ops[0] = Builder.CreateBitCast(Ops[0], SrcTy);
     if (Usgn)
       Ops[0] = Builder.CreateZExt(Ops[0], VTy);
@@ -1663,7 +1663,7 @@ Value *CodeGenFunction::EmitCommonNeonBuiltinExpr(
   }
   case NEON::BI__builtin_neon_vshrn_n_v: {
     llvm::FixedVectorType *SrcTy =
-        llvm::FixedVectorType::getExtendedElementVectorType(VTy);
+        llvm::FixedVectorType::getDoubleWidthElementVectorType(VTy);
     Ops[0] = Builder.CreateBitCast(Ops[0], SrcTy);
     Ops[1] = EmitNeonShiftVector(Ops[1], SrcTy, false);
     if (Usgn)
@@ -1728,7 +1728,7 @@ Value *CodeGenFunction::EmitCommonNeonBuiltinExpr(
   }
   case NEON::BI__builtin_neon_vsubhn_v: {
     llvm::FixedVectorType *SrcTy =
-        llvm::FixedVectorType::getExtendedElementVectorType(VTy);
+        llvm::FixedVectorType::getDoubleWidthElementVectorType(VTy);
 
     // %sum = add <4 x i32> %lhs, %rhs
     Ops[0] = Builder.CreateBitCast(Ops[0], SrcTy);
diff --git a/llvm/include/llvm/IR/DerivedTypes.h b/llvm/include/llvm/IR/DerivedTypes.h
index 0c686cc5c32d7..ebe7964efc161 100644
--- a/llvm/include/llvm/IR/DerivedTypes.h
+++ b/llvm/include/llvm/IR/DerivedTypes.h
@@ -66,12 +66,12 @@ class IntegerType : public Type {
   LLVM_ABI static IntegerType *get(LLVMContext &C, unsigned NumBits);
 
   /// Returns type twice as wide the input type.
-  IntegerType *getExtendedType() const {
+  IntegerType *getDoubleWidthType() const {
     return Type::getIntNTy(getContext(), 2 * getBitWidth());
   }
 
   /// Returns type half as wide the input type.
-  IntegerType *getTruncatedType() const {
+  IntegerType *getHalfWidthType() const {
     unsigned BitWidth = getBitWidth();
     assert((BitWidth & 1) == 0 &&
            "Cannot truncate integer type with odd bit-width");
@@ -540,16 +540,16 @@ class VectorType : public Type {
 
   /// This static method is like getInteger except that the element types are
   /// twice as wide as the elements in the input type.
-  static VectorType *getExtendedElementVectorType(VectorType *VTy) {
+  static VectorType *getDoubleWidthElementVectorType(VectorType *VTy) {
     assert(VTy->isIntOrIntVectorTy() && "VTy expected to be a vector of ints.");
     auto *EltTy = cast<IntegerType>(VTy->getElementType());
-    return VectorType::get(EltTy->getExtendedType(), VTy->getElementCount());
+    return VectorType::get(EltTy->getDoubleWidthType(), VTy->getElementCount());
   }
 
   // This static method gets a VectorType with the same number of elements as
   // the input type, and the element type is an integer or float type which
   // is half as wide as the elements in the input type.
-  static VectorType *getTruncatedElementVectorType(VectorType *VTy) {
+  static VectorType *getHalfWidthElementVectorType(VectorType *VTy) {
     Type *EltTy = VTy->getElementType();
     if (EltTy->isFloatingPointTy()) {
       switch (EltTy->getTypeID()) {
@@ -563,7 +563,7 @@ class VectorType : public Type {
         llvm_unreachable("Cannot create narrower fp vector element type");
       }
     } else {
-      EltTy = cast<IntegerType>(EltTy)->getTruncatedType();
+      EltTy = cast<IntegerType>(EltTy)->getHalfWidthType();
     }
     return VectorType::get(EltTy, VTy->getElementCount());
   }
@@ -574,7 +574,7 @@ class VectorType : public Type {
   static VectorType *getSubdividedVectorType(VectorType *VTy, int NumSubdivs) {
     for (int i = 0; i < NumSubdivs; ++i) {
       VTy = VectorType::getDoubleElementsVectorType(VTy);
-      VTy = VectorType::getTruncatedElementVectorType(VTy);
+      VTy = VectorType::getHalfWidthElementVectorType(VTy);
     }
     return VTy;
   }
@@ -655,13 +655,15 @@ class FixedVectorType : public VectorType {
     return cast<FixedVectorType>(VectorType::getInteger(VTy));
   }
 
-  static FixedVectorType *getExtendedElementVectorType(FixedVectorType *VTy) {
-    return cast<FixedVectorType>(VectorType::getExtendedElementVectorType(VTy));
+  static FixedVectorType *
+  getDoubleWidthElementVectorType(FixedVectorType *VTy) {
+    return cast<FixedVectorType>(
+        VectorType::getDoubleWidthElementVectorType(VTy));
   }
 
-  static FixedVectorType *getTruncatedElementVectorType(FixedVectorType *VTy) {
+  static FixedVectorType *getHalfWidthElementVectorType(FixedVectorType *VTy) {
     return cast<FixedVectorType>(
-        VectorType::getTruncatedElementVectorType(VTy));
+        VectorType::getHalfWidthElementVectorType(VTy));
   }
 
   static FixedVectorType *getSubdividedVectorType(FixedVectorType *VTy,
@@ -705,15 +707,15 @@ class ScalableVectorType : public VectorType {
   }
 
   static ScalableVectorType *
-  getExtendedElementVectorType(ScalableVectorType *VTy) {
+  getDoubleWidthElementVectorType(ScalableVectorType *VTy) {
     return cast<ScalableVectorType>(
-        VectorType::getExtendedElementVectorType(VTy));
+        VectorType::getDoubleWidthElementVectorType(VTy));
   }
 
   static ScalableVectorType *
-  getTruncatedElementVectorType(ScalableVectorType *VTy) {
+  getHalfWidthElementVectorType(ScalableVectorType *VTy) {
     return cast<ScalableVectorType>(
-        VectorType::getTruncatedElementVectorType(VTy));
+        VectorType::getHalfWidthElementVectorType(VTy));
   }
 
   static ScalableVectorType *getSubdividedVectorType(ScalableVectorType *VTy,
@@ -795,24 +797,24 @@ class PointerType : public Type {
   }
 };
 
-Type *Type::getExtendedType() const {
+Type *Type::getDoubleWidthType() const {
   assert(
       isIntOrIntVectorTy() &&
       "Original type expected to be a vector of integers or a scalar integer.");
   if (auto *VTy = dyn_cast<VectorType>(this))
-    return VectorType::getExtendedElementVectorType(
+    return VectorType::getDoubleWidthElementVectorType(
         const_cast<VectorType *>(VTy));
-  return cast<IntegerType>(this)->getExtendedType();
+  return cast<IntegerType>(this)->getDoubleWidthType();
 }
 
-Type *Type::getTruncatedType() const {
+Type *Type::getHalfWidthType() const {
   assert(
       isIntOrIntVectorTy() &&
       "Original type expected to be a vector of integers or a scalar integer.");
   if (auto *VTy = dyn_cast<VectorType>(this))
-    return VectorType::getTruncatedElementVectorType(
+    return VectorType::getHalfWidthElementVectorType(
         const_cast<VectorType *>(VTy));
-  return cast<IntegerType>(this)->getTruncatedType();
+  return cast<IntegerType>(this)->getHalfWidthType();
 }
 
 Type *Type::getWithNewType(Type *EltTy) const {
diff --git a/llvm/include/llvm/IR/Type.h b/llvm/include/llvm/IR/Type.h
index 7d40e5dac9463..4444733c4422d 100644
--- a/llvm/include/llvm/IR/Type.h
+++ b/llvm/include/llvm/IR/Type.h
@@ -442,11 +442,11 @@ class Type {
 
   /// Given scalar/vector integer type, returns a type with elements twice as
   /// wide as in the original type. For vectors, preserves element count.
-  LLVM_ABI inline Type *getExtendedType() const;
+  LLVM_ABI inline Type *getDoubleWidthType() const;
 
   /// Given scalar/vector integer type, returns a type with elements half as
   /// wide as in the original type. For vectors, preserves element count.
-  LLVM_ABI inline Type *getTruncatedType() const;
+  LLVM_ABI inline Type *getHalfWidthType() const;
 
   /// Get the address space of this pointer or pointer vector type.
   LLVM_ABI inline unsigned getPointerAddressSpace() const;
diff --git a/llvm/include/llvm/SandboxIR/Type.h b/llvm/include/llvm/SandboxIR/Type.h
index 9059c9661650b..e60d45703ab87 100644
--- a/llvm/include/llvm/SandboxIR/Type.h
+++ b/llvm/include/llvm/SandboxIR/Type.h
@@ -346,8 +346,8 @@ class VectorType : public Type {
     return cast<llvm::VectorType>(LLVMTy)->getElementCount();
   }
   LLVM_ABI static VectorType *getInteger(VectorType *VTy);
-  LLVM_ABI static VectorType *getExtendedElementVectorType(VectorType *VTy);
-  LLVM_ABI static VectorType *getTruncatedElementVectorType(VectorType *VTy);
+  LLVM_ABI static VectorType *getDoubleWidthElementVectorType(VectorType *VTy);
+  LLVM_ABI static VectorType *getHalfWidthElementVectorType(VectorType *VTy);
   LLVM_ABI static VectorType *getSubdividedVectorType(VectorType *VTy,
                                                       int NumSubdivs);
   LLVM_ABI static VectorType *getHalfElementsVectorType(VectorType *VTy);
@@ -371,13 +371,15 @@ class FixedVectorType : public VectorType {
     return cast<FixedVectorType>(VectorType::getInteger(VTy));
   }
 
-  static FixedVectorType *getExtendedElementVectorType(FixedVectorType *VTy) {
-    return cast<FixedVectorType>(VectorType::getExtendedElementVectorType(VTy));
+  static FixedVectorType *
+  getDoubleWidthElementVectorType(FixedVectorType *VTy) {
+    return cast<FixedVectorType>(
+        VectorType::getDoubleWidthElementVectorType(VTy));
   }
 
-  static FixedVectorType *getTruncatedElementVectorType(FixedVectorType *VTy) {
+  static FixedVectorType *getHalfWidthElementVectorType(FixedVectorType *VTy) {
     return cast<FixedVectorType>(
-        VectorType::getTruncatedElementVectorType(VTy));
+        VectorType::getHalfWidthElementVectorType(VTy));
   }
 
   static FixedVectorType *getSubdividedVectorType(FixedVectorType *VTy,
@@ -418,15 +420,15 @@ class ScalableVectorType : public VectorType {
   }
 
   static ScalableVectorType *
-  getExtendedElementVectorType(ScalableVectorType *VTy) {
+  getDoubleWidthElementVectorType(ScalableVectorType *VTy) {
     return cast<ScalableVectorType>(
-        VectorType::getExtendedElementVectorType(VTy));
+        VectorType::getDoubleWidthElementVectorType(VTy));
   }
 
   static ScalableVectorType *
-  getTruncatedElementVectorType(ScalableVectorType *VTy) {
+  getHalfWidthElementVectorType(ScalableVectorType *VTy) {
     return cast<ScalableVectorType>(
-        VectorType::getTruncatedElementVectorType(VTy));
+        VectorType::getHalfWidthElementVectorType(VTy));
   }
 
   static ScalableVectorType *getSubdividedVectorType(ScalableVectorType *VTy,
diff --git a/llvm/lib/Analysis/LoopCacheAnalysis.cpp b/llvm/lib/Analysis/LoopCacheAnalysis.cpp
index be4dfde85e8da..9b8d0c1811f3f 100644
--- a/llvm/lib/Analysis/LoopCacheAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopCacheAnalysis.cpp
@@ -329,7 +329,7 @@ CacheCostTy IndexedReference::computeRefCost(const Loop &L,
           computeTripCount(*AR->getLoop(), *Sizes.back(), SE);
       Type *WiderType = SE.getWiderType(RefCost->getType(), TripCount->getType());
       // For the multiplication result to fit, request a type twice as wide.
-      WiderType = WiderType->getExtendedType();
+      WiderType = WiderType->getDoubleWidthType();
       RefCost = SE.getMulExpr(SE.getNoopOrZeroExtend(RefCost, WiderType),
                               SE.getNoopOrZeroExtend(TripCount, WiderType));
     }
diff --git a/llvm/lib/IR/Intrinsics.cpp b/llvm/lib/IR/Intrinsics.cpp
index ff57d335c9a13..ea141cf186842 100644
--- a/llvm/lib/IR/Intrinsics.cpp
+++ b/llvm/lib/IR/Intrinsics.cpp
@@ -555,9 +555,9 @@ static Type *DecodeFixedType(ArrayRef<Intrinsic::IITDescriptor> &Infos,
   case IITDescriptor::VecOfAnyPtrsToElt:
     return OverloadTys[D.getOverloadIndex()];
   case IITDescriptor::Extend:
-    return OverloadTys[D.getOverloadIndex()]->getExtendedType();
+    return OverloadTys[D.getOverloadIndex()]->getDoubleWidthType();
   case IITDescriptor::Trunc:
-    return OverloadTys[D.getOverloadIndex()]->getTruncatedType();
+    return OverloadTys[D.getOverloadIndex()]->getHalfWidthType();
   case IITDescriptor::Subdivide2:
   case IITDescriptor::Subdivide4: {
     Type *Ty = OverloadTys[D.getOverloadIndex()];
@@ -948,7 +948,7 @@ matchIntrinsicType(Type *Ty, ArrayRef<Intrinsic::IITDescriptor> &Infos,
     if (D.getOverloadIndex() >= OverloadTys.size())
       return IsDeferredCheck || DeferCheck(Ty);
 
-    Type *NewTy = OverloadTys[D.getOverloadIndex()]->getExtendedType();
+    Type *NewTy = OverloadTys[D.getOverloadIndex()]->getDoubleWidthType();
     return Ty != NewTy;
   }
   case IITDescriptor::Trunc: {
@@ -956,7 +956,7 @@ matchIntrinsicType(Type *Ty, ArrayRef<Intrinsic::IITDescriptor> &Infos,
     if (D.getOverloadIndex() >= OverloadTys.size())
       return IsDeferredCheck || DeferCheck(Ty);
 
-    Type *NewTy = OverloadTys[D.getOverloadIndex()]->getTruncatedType();
+    Type *NewTy = OverloadTys[D.getOverloadIndex()]->getHalfWidthType();
     return Ty != NewTy;
   }
   case IITDescriptor::OneNthEltsVec: {
diff --git a/llvm/lib/SandboxIR/Type.cpp b/llvm/lib/SandboxIR/Type.cpp
index 4ae678f6673e5..1cac531e11f49 100644
--- a/llvm/lib/SandboxIR/Type.cpp
+++ b/llvm/lib/SandboxIR/Type.cpp
@@ -80,14 +80,14 @@ VectorType *VectorType::getInteger(VectorType *VTy) {
   return cast<VectorType>(VTy->getContext().getType(
       llvm::VectorType::getInteger(cast<llvm::VectorType>(VTy->LLVMTy))));
 }
-VectorType *VectorType::getExtendedElementVectorType(VectorType *VTy) {
-  return cast<VectorType>(
-      VTy->getContext().getType(llvm::VectorType::getExtendedElementVectorType(
+VectorType *VectorType::getDoubleWidthElementVectorType(VectorType *VTy) {
+  return cast<VectorType>(VTy->getContext().getType(
+      llvm::VectorType::getDoubleWidthElementVectorType(
           cast<llvm::VectorType>(VTy->LLVMTy))));
 }
-VectorType *VectorType::getTruncatedElementVectorType(VectorType *VTy) {
+VectorType *VectorType::getHalfWidthElementVectorType(VectorType *VTy) {
   return cast<VectorType>(
-      VTy->getContext().getType(llvm::VectorType::getTruncatedElementVectorType(
+      VTy->getContext().getType(llvm::VectorType::getHalfWidthElementVectorType(
           cast<llvm::VectorType>(VTy->LLVMTy))));
 }
 VectorType *VectorType::getSubdividedVectorType(VectorType *VTy,
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index b53605e917e2b..9dd549b29c614 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -18232,7 +18232,7 @@ bool AArch64TargetLowering::optimizeExtendOrTruncateConversion(
       return false;
 
     auto *TruncDstType =
-        cast<FixedVectorType>(VectorType::getTruncatedElementVectorType(DstTy));
+        cast<FixedVectorType>(VectorType::getHalfWidthElementVectorType(DstTy));
     // If the ZExt can be lowered to a single ZExt to the next power-of-2 and
     // the remaining ZExt folded into the user, don't use tbl lowering.
     auto SrcWidth = SrcTy->getElementType()->getScalarSizeInBits();
diff --git a/llvm/lib/Target/X86/X86InstCombineIntrinsic.cpp b/llvm/lib/Target/X86/X86InstCombineIntrinsic.cpp
index 932b4a416a8d3..60d68ebd285ea 100644
--- a/llvm/lib/Target/X86/X86InstCombineIntrinsic.cpp
+++ b/llvm/lib/Target/X86/X86InstCombineIntrinsic.cpp
@@ -532,7 +532,7 @@ static Value *simplifyX86pmulh(IntrinsicInst &II,
   // Extend to twice the width and multiply.
   auto Cast =
       IsSigned ? Instruction::CastOps::SExt : Instruction::CastOps::ZExt;
-  auto *ExtTy = FixedVectorType::getExtendedElementVectorType(ArgTy);
+  auto *ExtTy = FixedVectorType::getDoubleWidthElementVectorType(ArgTy);
   Value *LHS = Builder.CreateCast(Cast, Arg0, ExtTy);
   Value *RHS = Builder.CreateCast(Cast, Arg1, ExtTy);
   Value *Mul = Builder.CreateMul(LHS, RHS);
diff --git a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
index 1bc0ff397e476..92f2ff3c225ee 100644
--- a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
+++ b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
@@ -260,7 +260,7 @@ InstructionCost X86TTIImpl::getArithmeticInstrCost(
   if (Opcode == Instruction::Mul && Ty->isVectorTy() &&
       Ty->getPrimitiveSizeInBits() <= 64 && Ty->getScalarSizeInBits() == 8) {
     Type *WideVecTy =
-        VectorType::getExtendedElementVectorType(cast<VectorType>(Ty));
+        VectorType::getDoubleWidthElementVectorType(cast<VectorType>(Ty));
     return getCastInstrCost(Instruction::ZExt, WideVecTy, Ty,
                             TargetTransformInfo::CastContextHint::None,
                             CostKind) +
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
index 05508d84c036b..460d0fec9563e 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -1008,7 +1008,7 @@ Instruction *InstCombinerImpl::visitTrunc(TruncInst &Trunc) {
   // vectorization factors.
   if (auto *DestITy = dyn_cast<IntegerType>(DestTy)) {
     if (DestWidth * 2 < SrcWidth) {
-      auto *NewDestTy = DestITy->getExtendedType();
+      auto *NewDestTy = DestITy->getDoubleWidthType();
       if (shouldChangeType(SrcTy, NewDestTy) &&
           TypeEvaluationHelper::canEvaluateTruncated(Src, NewDestTy, *this,
                                                      &Trunc)) {
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
index 3547a79df1355..d016011507d71 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
@@ -213,7 +213,7 @@ dropRedundantMaskingOfLeftShiftInput(BinaryOperator *OuterShift,
 
   // The mask must be computed in a type twice as wide to ensure
   // that no bits are lost if the sum-of-shifts is wider than the base type.
-  Type *ExtendedTy = WidestTy->getExtendedType();
+  Type *ExtendedTy = WidestTy->getDoubleWidthType();
 
   Value *MaskShAmt;
 
diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index 5ba344ea9a808..8b6f6614501a7 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -5512,7 +5512,7 @@ bool VectorCombine::foldInterleaveIntrinsics(Instruction &I) {
 
   auto *VTy =
       cast<VectorType>(cast<IntrinsicInst>(I).getArgOperand(0)->getType());
-  auto *ExtVTy = VectorType::getExtendedElementVectorType(VTy);
+  auto *ExtVTy = VectorType::getDoubleWidthElementVectorType(VTy);
   unsigned Width = VTy->getElementType()->getIntegerBitWidth();
 
   // Just in case the cost of interleave2 intrinsic and bitcast are both
diff --git a/llvm/unittests/IR/VectorTypesTest.cpp b/llvm/unittests/IR/VectorTypesTest.cpp
index 0b0787a11c418..7984000e121ff 100644
--- a/llvm/unittests/IR/VectorTypesTest.cpp
+++ b/llvm/unittests/IR/VectorTyp...
[truncated]

@llvmorg-github-actions
Copy link
Copy Markdown

@llvm/pr-subscribers-backend-x86

Author: Rahul Joshi (jurahul)

Changes

getTruncated and getExtended are too generic names, so rename them as follows:

  • getTruncatedType -> getHalfWidthType
  • getExtendedType -> getDoubleWidthType
  • getTruncatedElementVectorType -> getHalfWidthElementVectorType
  • getExtendedElementVectorType -> getDoubleWidthElementVectorType

These new names convey the semantics more precisely.


Patch is 24.51 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/196528.diff

15 Files Affected:

  • (modified) clang/lib/CodeGen/TargetBuiltins/ARM.cpp (+7-7)
  • (modified) llvm/include/llvm/IR/DerivedTypes.h (+23-21)
  • (modified) llvm/include/llvm/IR/Type.h (+2-2)
  • (modified) llvm/include/llvm/SandboxIR/Type.h (+12-10)
  • (modified) llvm/lib/Analysis/LoopCacheAnalysis.cpp (+1-1)
  • (modified) llvm/lib/IR/Intrinsics.cpp (+4-4)
  • (modified) llvm/lib/SandboxIR/Type.cpp (+5-5)
  • (modified) llvm/lib/Target/AArch64/AArch64ISelLowering.cpp (+1-1)
  • (modified) llvm/lib/Target/X86/X86InstCombineIntrinsic.cpp (+1-1)
  • (modified) llvm/lib/Target/X86/X86TargetTransformInfo.cpp (+1-1)
  • (modified) llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp (+1-1)
  • (modified) llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp (+1-1)
  • (modified) llvm/lib/Transforms/Vectorize/VectorCombine.cpp (+1-1)
  • (modified) llvm/unittests/IR/VectorTypesTest.cpp (+4-4)
  • (modified) llvm/unittests/SandboxIR/TypesTest.cpp (+10-9)
diff --git a/clang/lib/CodeGen/TargetBuiltins/ARM.cpp b/clang/lib/CodeGen/TargetBuiltins/ARM.cpp
index 8bfacc5580bd6..8d237f51ed0b0 100644
--- a/clang/lib/CodeGen/TargetBuiltins/ARM.cpp
+++ b/clang/lib/CodeGen/TargetBuiltins/ARM.cpp
@@ -1256,7 +1256,7 @@ Value *CodeGenFunction::EmitCommonNeonBuiltinExpr(
   }
   case NEON::BI__builtin_neon_vaddhn_v: {
     llvm::FixedVectorType *SrcTy =
-        llvm::FixedVectorType::getExtendedElementVectorType(VTy);
+        llvm::FixedVectorType::getDoubleWidthElementVectorType(VTy);
 
     // %sum = add <4 x i32> %lhs, %rhs
     Ops[0] = Builder.CreateBitCast(Ops[0], SrcTy);
@@ -1455,7 +1455,7 @@ Value *CodeGenFunction::EmitCommonNeonBuiltinExpr(
     return EmitNeonCall(CGM.getIntrinsic(LLVMIntrinsic, Tys), Ops, NameHint);
   }
   case NEON::BI__builtin_neon_vcvtx_f32_v: {
-    llvm::Type *Tys[2] = { VTy->getTruncatedElementVectorType(VTy), Ty};
+    llvm::Type *Tys[2] = {VTy->getHalfWidthElementVectorType(VTy), Ty};
     return EmitNeonCall(CGM.getIntrinsic(LLVMIntrinsic, Tys), Ops, NameHint);
 
   }
@@ -1541,7 +1541,7 @@ Value *CodeGenFunction::EmitCommonNeonBuiltinExpr(
   }
   case NEON::BI__builtin_neon_vmovl_v: {
     llvm::FixedVectorType *DTy =
-        llvm::FixedVectorType::getTruncatedElementVectorType(VTy);
+        llvm::FixedVectorType::getHalfWidthElementVectorType(VTy);
     Ops[0] = Builder.CreateBitCast(Ops[0], DTy);
     if (Usgn)
       return Builder.CreateZExt(Ops[0], Ty, "vmovl");
@@ -1549,7 +1549,7 @@ Value *CodeGenFunction::EmitCommonNeonBuiltinExpr(
   }
   case NEON::BI__builtin_neon_vmovn_v: {
     llvm::FixedVectorType *QTy =
-        llvm::FixedVectorType::getExtendedElementVectorType(VTy);
+        llvm::FixedVectorType::getDoubleWidthElementVectorType(VTy);
     Ops[0] = Builder.CreateBitCast(Ops[0], QTy);
     return Builder.CreateTrunc(Ops[0], Ty, "vmovn");
   }
@@ -1652,7 +1652,7 @@ Value *CodeGenFunction::EmitCommonNeonBuiltinExpr(
                              "vshl_n");
   case NEON::BI__builtin_neon_vshll_n_v: {
     llvm::FixedVectorType *SrcTy =
-        llvm::FixedVectorType::getTruncatedElementVectorType(VTy);
+        llvm::FixedVectorType::getHalfWidthElementVectorType(VTy);
     Ops[0] = Builder.CreateBitCast(Ops[0], SrcTy);
     if (Usgn)
       Ops[0] = Builder.CreateZExt(Ops[0], VTy);
@@ -1663,7 +1663,7 @@ Value *CodeGenFunction::EmitCommonNeonBuiltinExpr(
   }
   case NEON::BI__builtin_neon_vshrn_n_v: {
     llvm::FixedVectorType *SrcTy =
-        llvm::FixedVectorType::getExtendedElementVectorType(VTy);
+        llvm::FixedVectorType::getDoubleWidthElementVectorType(VTy);
     Ops[0] = Builder.CreateBitCast(Ops[0], SrcTy);
     Ops[1] = EmitNeonShiftVector(Ops[1], SrcTy, false);
     if (Usgn)
@@ -1728,7 +1728,7 @@ Value *CodeGenFunction::EmitCommonNeonBuiltinExpr(
   }
   case NEON::BI__builtin_neon_vsubhn_v: {
     llvm::FixedVectorType *SrcTy =
-        llvm::FixedVectorType::getExtendedElementVectorType(VTy);
+        llvm::FixedVectorType::getDoubleWidthElementVectorType(VTy);
 
     // %sum = add <4 x i32> %lhs, %rhs
     Ops[0] = Builder.CreateBitCast(Ops[0], SrcTy);
diff --git a/llvm/include/llvm/IR/DerivedTypes.h b/llvm/include/llvm/IR/DerivedTypes.h
index 0c686cc5c32d7..ebe7964efc161 100644
--- a/llvm/include/llvm/IR/DerivedTypes.h
+++ b/llvm/include/llvm/IR/DerivedTypes.h
@@ -66,12 +66,12 @@ class IntegerType : public Type {
   LLVM_ABI static IntegerType *get(LLVMContext &C, unsigned NumBits);
 
   /// Returns type twice as wide the input type.
-  IntegerType *getExtendedType() const {
+  IntegerType *getDoubleWidthType() const {
     return Type::getIntNTy(getContext(), 2 * getBitWidth());
   }
 
   /// Returns type half as wide the input type.
-  IntegerType *getTruncatedType() const {
+  IntegerType *getHalfWidthType() const {
     unsigned BitWidth = getBitWidth();
     assert((BitWidth & 1) == 0 &&
            "Cannot truncate integer type with odd bit-width");
@@ -540,16 +540,16 @@ class VectorType : public Type {
 
   /// This static method is like getInteger except that the element types are
   /// twice as wide as the elements in the input type.
-  static VectorType *getExtendedElementVectorType(VectorType *VTy) {
+  static VectorType *getDoubleWidthElementVectorType(VectorType *VTy) {
     assert(VTy->isIntOrIntVectorTy() && "VTy expected to be a vector of ints.");
     auto *EltTy = cast<IntegerType>(VTy->getElementType());
-    return VectorType::get(EltTy->getExtendedType(), VTy->getElementCount());
+    return VectorType::get(EltTy->getDoubleWidthType(), VTy->getElementCount());
   }
 
   // This static method gets a VectorType with the same number of elements as
   // the input type, and the element type is an integer or float type which
   // is half as wide as the elements in the input type.
-  static VectorType *getTruncatedElementVectorType(VectorType *VTy) {
+  static VectorType *getHalfWidthElementVectorType(VectorType *VTy) {
     Type *EltTy = VTy->getElementType();
     if (EltTy->isFloatingPointTy()) {
       switch (EltTy->getTypeID()) {
@@ -563,7 +563,7 @@ class VectorType : public Type {
         llvm_unreachable("Cannot create narrower fp vector element type");
       }
     } else {
-      EltTy = cast<IntegerType>(EltTy)->getTruncatedType();
+      EltTy = cast<IntegerType>(EltTy)->getHalfWidthType();
     }
     return VectorType::get(EltTy, VTy->getElementCount());
   }
@@ -574,7 +574,7 @@ class VectorType : public Type {
   static VectorType *getSubdividedVectorType(VectorType *VTy, int NumSubdivs) {
     for (int i = 0; i < NumSubdivs; ++i) {
       VTy = VectorType::getDoubleElementsVectorType(VTy);
-      VTy = VectorType::getTruncatedElementVectorType(VTy);
+      VTy = VectorType::getHalfWidthElementVectorType(VTy);
     }
     return VTy;
   }
@@ -655,13 +655,15 @@ class FixedVectorType : public VectorType {
     return cast<FixedVectorType>(VectorType::getInteger(VTy));
   }
 
-  static FixedVectorType *getExtendedElementVectorType(FixedVectorType *VTy) {
-    return cast<FixedVectorType>(VectorType::getExtendedElementVectorType(VTy));
+  static FixedVectorType *
+  getDoubleWidthElementVectorType(FixedVectorType *VTy) {
+    return cast<FixedVectorType>(
+        VectorType::getDoubleWidthElementVectorType(VTy));
   }
 
-  static FixedVectorType *getTruncatedElementVectorType(FixedVectorType *VTy) {
+  static FixedVectorType *getHalfWidthElementVectorType(FixedVectorType *VTy) {
     return cast<FixedVectorType>(
-        VectorType::getTruncatedElementVectorType(VTy));
+        VectorType::getHalfWidthElementVectorType(VTy));
   }
 
   static FixedVectorType *getSubdividedVectorType(FixedVectorType *VTy,
@@ -705,15 +707,15 @@ class ScalableVectorType : public VectorType {
   }
 
   static ScalableVectorType *
-  getExtendedElementVectorType(ScalableVectorType *VTy) {
+  getDoubleWidthElementVectorType(ScalableVectorType *VTy) {
     return cast<ScalableVectorType>(
-        VectorType::getExtendedElementVectorType(VTy));
+        VectorType::getDoubleWidthElementVectorType(VTy));
   }
 
   static ScalableVectorType *
-  getTruncatedElementVectorType(ScalableVectorType *VTy) {
+  getHalfWidthElementVectorType(ScalableVectorType *VTy) {
     return cast<ScalableVectorType>(
-        VectorType::getTruncatedElementVectorType(VTy));
+        VectorType::getHalfWidthElementVectorType(VTy));
   }
 
   static ScalableVectorType *getSubdividedVectorType(ScalableVectorType *VTy,
@@ -795,24 +797,24 @@ class PointerType : public Type {
   }
 };
 
-Type *Type::getExtendedType() const {
+Type *Type::getDoubleWidthType() const {
   assert(
       isIntOrIntVectorTy() &&
       "Original type expected to be a vector of integers or a scalar integer.");
   if (auto *VTy = dyn_cast<VectorType>(this))
-    return VectorType::getExtendedElementVectorType(
+    return VectorType::getDoubleWidthElementVectorType(
         const_cast<VectorType *>(VTy));
-  return cast<IntegerType>(this)->getExtendedType();
+  return cast<IntegerType>(this)->getDoubleWidthType();
 }
 
-Type *Type::getTruncatedType() const {
+Type *Type::getHalfWidthType() const {
   assert(
       isIntOrIntVectorTy() &&
       "Original type expected to be a vector of integers or a scalar integer.");
   if (auto *VTy = dyn_cast<VectorType>(this))
-    return VectorType::getTruncatedElementVectorType(
+    return VectorType::getHalfWidthElementVectorType(
         const_cast<VectorType *>(VTy));
-  return cast<IntegerType>(this)->getTruncatedType();
+  return cast<IntegerType>(this)->getHalfWidthType();
 }
 
 Type *Type::getWithNewType(Type *EltTy) const {
diff --git a/llvm/include/llvm/IR/Type.h b/llvm/include/llvm/IR/Type.h
index 7d40e5dac9463..4444733c4422d 100644
--- a/llvm/include/llvm/IR/Type.h
+++ b/llvm/include/llvm/IR/Type.h
@@ -442,11 +442,11 @@ class Type {
 
   /// Given scalar/vector integer type, returns a type with elements twice as
   /// wide as in the original type. For vectors, preserves element count.
-  LLVM_ABI inline Type *getExtendedType() const;
+  LLVM_ABI inline Type *getDoubleWidthType() const;
 
   /// Given scalar/vector integer type, returns a type with elements half as
   /// wide as in the original type. For vectors, preserves element count.
-  LLVM_ABI inline Type *getTruncatedType() const;
+  LLVM_ABI inline Type *getHalfWidthType() const;
 
   /// Get the address space of this pointer or pointer vector type.
   LLVM_ABI inline unsigned getPointerAddressSpace() const;
diff --git a/llvm/include/llvm/SandboxIR/Type.h b/llvm/include/llvm/SandboxIR/Type.h
index 9059c9661650b..e60d45703ab87 100644
--- a/llvm/include/llvm/SandboxIR/Type.h
+++ b/llvm/include/llvm/SandboxIR/Type.h
@@ -346,8 +346,8 @@ class VectorType : public Type {
     return cast<llvm::VectorType>(LLVMTy)->getElementCount();
   }
   LLVM_ABI static VectorType *getInteger(VectorType *VTy);
-  LLVM_ABI static VectorType *getExtendedElementVectorType(VectorType *VTy);
-  LLVM_ABI static VectorType *getTruncatedElementVectorType(VectorType *VTy);
+  LLVM_ABI static VectorType *getDoubleWidthElementVectorType(VectorType *VTy);
+  LLVM_ABI static VectorType *getHalfWidthElementVectorType(VectorType *VTy);
   LLVM_ABI static VectorType *getSubdividedVectorType(VectorType *VTy,
                                                       int NumSubdivs);
   LLVM_ABI static VectorType *getHalfElementsVectorType(VectorType *VTy);
@@ -371,13 +371,15 @@ class FixedVectorType : public VectorType {
     return cast<FixedVectorType>(VectorType::getInteger(VTy));
   }
 
-  static FixedVectorType *getExtendedElementVectorType(FixedVectorType *VTy) {
-    return cast<FixedVectorType>(VectorType::getExtendedElementVectorType(VTy));
+  static FixedVectorType *
+  getDoubleWidthElementVectorType(FixedVectorType *VTy) {
+    return cast<FixedVectorType>(
+        VectorType::getDoubleWidthElementVectorType(VTy));
   }
 
-  static FixedVectorType *getTruncatedElementVectorType(FixedVectorType *VTy) {
+  static FixedVectorType *getHalfWidthElementVectorType(FixedVectorType *VTy) {
     return cast<FixedVectorType>(
-        VectorType::getTruncatedElementVectorType(VTy));
+        VectorType::getHalfWidthElementVectorType(VTy));
   }
 
   static FixedVectorType *getSubdividedVectorType(FixedVectorType *VTy,
@@ -418,15 +420,15 @@ class ScalableVectorType : public VectorType {
   }
 
   static ScalableVectorType *
-  getExtendedElementVectorType(ScalableVectorType *VTy) {
+  getDoubleWidthElementVectorType(ScalableVectorType *VTy) {
     return cast<ScalableVectorType>(
-        VectorType::getExtendedElementVectorType(VTy));
+        VectorType::getDoubleWidthElementVectorType(VTy));
   }
 
   static ScalableVectorType *
-  getTruncatedElementVectorType(ScalableVectorType *VTy) {
+  getHalfWidthElementVectorType(ScalableVectorType *VTy) {
     return cast<ScalableVectorType>(
-        VectorType::getTruncatedElementVectorType(VTy));
+        VectorType::getHalfWidthElementVectorType(VTy));
   }
 
   static ScalableVectorType *getSubdividedVectorType(ScalableVectorType *VTy,
diff --git a/llvm/lib/Analysis/LoopCacheAnalysis.cpp b/llvm/lib/Analysis/LoopCacheAnalysis.cpp
index be4dfde85e8da..9b8d0c1811f3f 100644
--- a/llvm/lib/Analysis/LoopCacheAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopCacheAnalysis.cpp
@@ -329,7 +329,7 @@ CacheCostTy IndexedReference::computeRefCost(const Loop &L,
           computeTripCount(*AR->getLoop(), *Sizes.back(), SE);
       Type *WiderType = SE.getWiderType(RefCost->getType(), TripCount->getType());
       // For the multiplication result to fit, request a type twice as wide.
-      WiderType = WiderType->getExtendedType();
+      WiderType = WiderType->getDoubleWidthType();
       RefCost = SE.getMulExpr(SE.getNoopOrZeroExtend(RefCost, WiderType),
                               SE.getNoopOrZeroExtend(TripCount, WiderType));
     }
diff --git a/llvm/lib/IR/Intrinsics.cpp b/llvm/lib/IR/Intrinsics.cpp
index ff57d335c9a13..ea141cf186842 100644
--- a/llvm/lib/IR/Intrinsics.cpp
+++ b/llvm/lib/IR/Intrinsics.cpp
@@ -555,9 +555,9 @@ static Type *DecodeFixedType(ArrayRef<Intrinsic::IITDescriptor> &Infos,
   case IITDescriptor::VecOfAnyPtrsToElt:
     return OverloadTys[D.getOverloadIndex()];
   case IITDescriptor::Extend:
-    return OverloadTys[D.getOverloadIndex()]->getExtendedType();
+    return OverloadTys[D.getOverloadIndex()]->getDoubleWidthType();
   case IITDescriptor::Trunc:
-    return OverloadTys[D.getOverloadIndex()]->getTruncatedType();
+    return OverloadTys[D.getOverloadIndex()]->getHalfWidthType();
   case IITDescriptor::Subdivide2:
   case IITDescriptor::Subdivide4: {
     Type *Ty = OverloadTys[D.getOverloadIndex()];
@@ -948,7 +948,7 @@ matchIntrinsicType(Type *Ty, ArrayRef<Intrinsic::IITDescriptor> &Infos,
     if (D.getOverloadIndex() >= OverloadTys.size())
       return IsDeferredCheck || DeferCheck(Ty);
 
-    Type *NewTy = OverloadTys[D.getOverloadIndex()]->getExtendedType();
+    Type *NewTy = OverloadTys[D.getOverloadIndex()]->getDoubleWidthType();
     return Ty != NewTy;
   }
   case IITDescriptor::Trunc: {
@@ -956,7 +956,7 @@ matchIntrinsicType(Type *Ty, ArrayRef<Intrinsic::IITDescriptor> &Infos,
     if (D.getOverloadIndex() >= OverloadTys.size())
       return IsDeferredCheck || DeferCheck(Ty);
 
-    Type *NewTy = OverloadTys[D.getOverloadIndex()]->getTruncatedType();
+    Type *NewTy = OverloadTys[D.getOverloadIndex()]->getHalfWidthType();
     return Ty != NewTy;
   }
   case IITDescriptor::OneNthEltsVec: {
diff --git a/llvm/lib/SandboxIR/Type.cpp b/llvm/lib/SandboxIR/Type.cpp
index 4ae678f6673e5..1cac531e11f49 100644
--- a/llvm/lib/SandboxIR/Type.cpp
+++ b/llvm/lib/SandboxIR/Type.cpp
@@ -80,14 +80,14 @@ VectorType *VectorType::getInteger(VectorType *VTy) {
   return cast<VectorType>(VTy->getContext().getType(
       llvm::VectorType::getInteger(cast<llvm::VectorType>(VTy->LLVMTy))));
 }
-VectorType *VectorType::getExtendedElementVectorType(VectorType *VTy) {
-  return cast<VectorType>(
-      VTy->getContext().getType(llvm::VectorType::getExtendedElementVectorType(
+VectorType *VectorType::getDoubleWidthElementVectorType(VectorType *VTy) {
+  return cast<VectorType>(VTy->getContext().getType(
+      llvm::VectorType::getDoubleWidthElementVectorType(
           cast<llvm::VectorType>(VTy->LLVMTy))));
 }
-VectorType *VectorType::getTruncatedElementVectorType(VectorType *VTy) {
+VectorType *VectorType::getHalfWidthElementVectorType(VectorType *VTy) {
   return cast<VectorType>(
-      VTy->getContext().getType(llvm::VectorType::getTruncatedElementVectorType(
+      VTy->getContext().getType(llvm::VectorType::getHalfWidthElementVectorType(
           cast<llvm::VectorType>(VTy->LLVMTy))));
 }
 VectorType *VectorType::getSubdividedVectorType(VectorType *VTy,
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index b53605e917e2b..9dd549b29c614 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -18232,7 +18232,7 @@ bool AArch64TargetLowering::optimizeExtendOrTruncateConversion(
       return false;
 
     auto *TruncDstType =
-        cast<FixedVectorType>(VectorType::getTruncatedElementVectorType(DstTy));
+        cast<FixedVectorType>(VectorType::getHalfWidthElementVectorType(DstTy));
     // If the ZExt can be lowered to a single ZExt to the next power-of-2 and
     // the remaining ZExt folded into the user, don't use tbl lowering.
     auto SrcWidth = SrcTy->getElementType()->getScalarSizeInBits();
diff --git a/llvm/lib/Target/X86/X86InstCombineIntrinsic.cpp b/llvm/lib/Target/X86/X86InstCombineIntrinsic.cpp
index 932b4a416a8d3..60d68ebd285ea 100644
--- a/llvm/lib/Target/X86/X86InstCombineIntrinsic.cpp
+++ b/llvm/lib/Target/X86/X86InstCombineIntrinsic.cpp
@@ -532,7 +532,7 @@ static Value *simplifyX86pmulh(IntrinsicInst &II,
   // Extend to twice the width and multiply.
   auto Cast =
       IsSigned ? Instruction::CastOps::SExt : Instruction::CastOps::ZExt;
-  auto *ExtTy = FixedVectorType::getExtendedElementVectorType(ArgTy);
+  auto *ExtTy = FixedVectorType::getDoubleWidthElementVectorType(ArgTy);
   Value *LHS = Builder.CreateCast(Cast, Arg0, ExtTy);
   Value *RHS = Builder.CreateCast(Cast, Arg1, ExtTy);
   Value *Mul = Builder.CreateMul(LHS, RHS);
diff --git a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
index 1bc0ff397e476..92f2ff3c225ee 100644
--- a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
+++ b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
@@ -260,7 +260,7 @@ InstructionCost X86TTIImpl::getArithmeticInstrCost(
   if (Opcode == Instruction::Mul && Ty->isVectorTy() &&
       Ty->getPrimitiveSizeInBits() <= 64 && Ty->getScalarSizeInBits() == 8) {
     Type *WideVecTy =
-        VectorType::getExtendedElementVectorType(cast<VectorType>(Ty));
+        VectorType::getDoubleWidthElementVectorType(cast<VectorType>(Ty));
     return getCastInstrCost(Instruction::ZExt, WideVecTy, Ty,
                             TargetTransformInfo::CastContextHint::None,
                             CostKind) +
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
index 05508d84c036b..460d0fec9563e 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -1008,7 +1008,7 @@ Instruction *InstCombinerImpl::visitTrunc(TruncInst &Trunc) {
   // vectorization factors.
   if (auto *DestITy = dyn_cast<IntegerType>(DestTy)) {
     if (DestWidth * 2 < SrcWidth) {
-      auto *NewDestTy = DestITy->getExtendedType();
+      auto *NewDestTy = DestITy->getDoubleWidthType();
       if (shouldChangeType(SrcTy, NewDestTy) &&
           TypeEvaluationHelper::canEvaluateTruncated(Src, NewDestTy, *this,
                                                      &Trunc)) {
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
index 3547a79df1355..d016011507d71 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
@@ -213,7 +213,7 @@ dropRedundantMaskingOfLeftShiftInput(BinaryOperator *OuterShift,
 
   // The mask must be computed in a type twice as wide to ensure
   // that no bits are lost if the sum-of-shifts is wider than the base type.
-  Type *ExtendedTy = WidestTy->getExtendedType();
+  Type *ExtendedTy = WidestTy->getDoubleWidthType();
 
   Value *MaskShAmt;
 
diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index 5ba344ea9a808..8b6f6614501a7 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -5512,7 +5512,7 @@ bool VectorCombine::foldInterleaveIntrinsics(Instruction &I) {
 
   auto *VTy =
       cast<VectorType>(cast<IntrinsicInst>(I).getArgOperand(0)->getType());
-  auto *ExtVTy = VectorType::getExtendedElementVectorType(VTy);
+  auto *ExtVTy = VectorType::getDoubleWidthElementVectorType(VTy);
   unsigned Width = VTy->getElementType()->getIntegerBitWidth();
 
   // Just in case the cost of interleave2 intrinsic and bitcast are both
diff --git a/llvm/unittests/IR/VectorTypesTest.cpp b/llvm/unittests/IR/VectorTypesTest.cpp
index 0b0787a11c418..7984000e121ff 100644
--- a/llvm/unittests/IR/VectorTypesTest.cpp
+++ b/llvm/unittests/IR/VectorTyp...
[truncated]

@jurahul
Copy link
Copy Markdown
Contributor Author

jurahul commented May 8, 2026

These are the new names @s-barannikov suggested in the other PR. PTAL and see if these are better names.

@topperc
Copy link
Copy Markdown
Contributor

topperc commented May 8, 2026

Function names in the PR title are missing the word "Type"

@jurahul jurahul changed the title [LLVM] Rename Type::getTruncated() and Type::getExtended() [LLVM] Rename Type::getTruncatedType() and Type::getExtendedType() May 8, 2026
@jurahul
Copy link
Copy Markdown
Contributor Author

jurahul commented May 8, 2026

Function names in the PR title are missing the word "Type"

Fixed. Thanks

@jurahul
Copy link
Copy Markdown
Contributor Author

jurahul commented May 13, 2026

@nikic @s-barannikov any opinions on this rename?

Copy link
Copy Markdown
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced that the proposed new names are an improvement. "double width" is ambiguous wrt doubling the scalar width or doubling the type width in a way that "extend" is not.

@s-barannikov
Copy link
Copy Markdown
Contributor

"extend" does not say that it "extends" the bitwidth exactly twice. Same for "truncate".

The current naming system still confuses me, but since I can't suggest a clear unambiguous alternative, let's leave it as is.

@s-barannikov
Copy link
Copy Markdown
Contributor

"double width" is ambiguous wrt doubling the scalar width or doubling the type width

It is actually "double width element". I would agree otherwise.

@nikic
Copy link
Copy Markdown
Contributor

nikic commented May 13, 2026

"double width" is ambiguous wrt doubling the scalar width or doubling the type width

It is actually "double width element". I would agree otherwise.

The main APIs (on Type rather than on VectorType / IntegerType) are called getDoubleWidthType() and getHalfWidthType().

@s-barannikov
Copy link
Copy Markdown
Contributor

"double width" is ambiguous wrt doubling the scalar width or doubling the type width

It is actually "double width element". I would agree otherwise.

The main APIs (on Type rather than on VectorType / IntegerType) are called getDoubleWidthType() and getHalfWidthType().

Right... I should have looked more closely.

@jurahul
Copy link
Copy Markdown
Contributor Author

jurahul commented May 13, 2026

SG, I don't have any strong preference either. Will close this PR.

@jurahul jurahul closed this May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend:AArch64 backend:X86 clang:codegen IR generation bugs: mangling, exceptions, etc. llvm:analysis Includes value tracking, cost tables and constant folding llvm:instcombine Covers the InstCombine, InstSimplify and AggressiveInstCombine passes llvm:ir llvm:SandboxIR llvm:transforms llvm:vectorcombine vectorizers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants