Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the x86_mmx IR type. #98505

Merged
merged 11 commits into from
Jul 25, 2024
Merged

Remove the x86_mmx IR type. #98505

merged 11 commits into from
Jul 25, 2024

Conversation

jyknight
Copy link
Member

@jyknight jyknight commented Jul 11, 2024

It is now translated to <1 x i64>, which allows the removal of a bunch of special casing.

This incompatibly changes the ABI of any LLVM IR function with x86_mmx arguments or returns: instead of passing in mmx registers, they will now be passed via integer registers. However, the real-world incompatibility caused by this is expected to be minimal, because Clang never uses the x86_mmx type -- it lowers __m64 to either <1 x i64> or double, depending on ABI.

This change does not eliminate the SelectionDAG MVT::x86mmx type. That type simply no longer corresponds to an IR type, and is used only by MMX intrinsics and inline-asm operands.

Because SelectionDAGBuilder only knows how to generate the operands/results of intrinsics based on the IR type, it thus now generates the intrinsics with the type MVT::v1i64, instead of MVT::x86mmx. We need to fix this before the DAG LegalizeTypes, and thus have the X86 backend fix them up in DAGCombine. (This may be a short-lived hack, if all the MMX intrinsics can be removed in upcoming changes.)

Works towards issue #98272.

jyknight added 3 commits July 10, 2024 18:57
The SelectionDAG asm-lowering code can already handle conversion of other vector types to MMX if needed.
It is now translated to `<1 x i64>`, which allows the removal of a bunch of special casing.

This changes the ABI of any LLVM IR function with `x86_mmx` arguments or returns: instead of passing in mmx registers, it will now pass via integer registers. However, the real-world incompatibility generated by this is minimal, since Clang never uses the x86_mmx type -- it lowers `__m64` to either `<1 x i64>` or `double`, depending on ABI.

This change does _not_ eliminate the SelectionDAG `MVT::x86mmx` type. That no longer corresponds to an IR type, and is used only by MMX intrinsics and inline-asm operands.

In order to correctly handle the MMX intrinsics, a hack has been added to `SelectionDAGBuilder::visitTargetIntrinsic`, because there's no generic way to specify a custom translation from LLVM IR type to SelectionDAG type for an intrinsic lowering. (This may be a short-lived hack, if all the MMX intrinsics can be removed in upcoming changes.)
@llvmbot
Copy link
Member

llvmbot commented Jul 11, 2024

@llvm/pr-subscribers-llvm-transforms
@llvm/pr-subscribers-llvm-ir
@llvm/pr-subscribers-compiler-rt-sanitizer
@llvm/pr-subscribers-backend-directx
@llvm/pr-subscribers-mlir
@llvm/pr-subscribers-llvm-analysis
@llvm/pr-subscribers-backend-hexagon
@llvm/pr-subscribers-mlir-llvm

@llvm/pr-subscribers-clang

Author: James Y Knight (jyknight)

Changes

It is now translated to &lt;1 x i64&gt;, which allows the removal of a bunch of special casing.

This incompatibly changes the ABI of any LLVM IR function with x86_mmx arguments or returns: instead of passing in mmx registers, they will now be passed via integer registers. However, the real-world incompatibility caused by this is expected to be minimal, because Clang never uses the x86_mmx type -- it lowers __m64 to either &lt;1 x i64&gt; or double, depending on ABI.

This change does not eliminate the SelectionDAG MVT::x86mmx type. That type simply no longer corresponds to an IR type, and is used only by MMX intrinsics and inline-asm operands.

Because SelectionDAGBuilder only knows how to generate the operands/results of intrinsics based on the IR type, it thus now generates the intrinsics with the type MVT::v1i64, instead of MVT::x86mmx. We need to fix this before the DAG LegalizeTypes, and thus have the X86 backend fix them up in DAGCombine. (This may be a short-lived hack, if all the MMX intrinsics can be removed in upcoming changes.)

Works towards issue #98272.

(Note: depends on #98273; that should be submitted first)


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

90 Files Affected:

  • (modified) clang/lib/CodeGen/CGBuiltin.cpp (+2-2)
  • (modified) clang/lib/CodeGen/Targets/X86.cpp (-13)
  • (modified) clang/test/CodeGen/X86/mmx-inline-asm.c (+1-1)
  • (modified) clang/test/CodeGen/asm-inout.c (+3-3)
  • (modified) llvm/bindings/ocaml/llvm/llvm.mli (-4)
  • (modified) llvm/bindings/ocaml/llvm/llvm_ocaml.c (-5)
  • (modified) llvm/include/llvm-c/Core.h (+21-27)
  • (modified) llvm/include/llvm/IR/DataLayout.h (-1)
  • (modified) llvm/include/llvm/IR/Type.h (+3-9)
  • (modified) llvm/lib/Analysis/ConstantFolding.cpp (+3-5)
  • (modified) llvm/lib/AsmParser/LLLexer.cpp (+2-1)
  • (modified) llvm/lib/Bitcode/Reader/BitcodeReader.cpp (+3-1)
  • (modified) llvm/lib/Bitcode/Writer/BitcodeWriter.cpp (+3-2)
  • (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (+1)
  • (modified) llvm/lib/CodeGen/ValueTypes.cpp (+3-4)
  • (modified) llvm/lib/IR/AsmWriter.cpp (+3-2)
  • (modified) llvm/lib/IR/ConstantFold.cpp (+1-1)
  • (modified) llvm/lib/IR/Core.cpp (-8)
  • (modified) llvm/lib/IR/DataLayout.cpp (-1)
  • (modified) llvm/lib/IR/Function.cpp (+10-4)
  • (modified) llvm/lib/IR/Instructions.cpp (-9)
  • (modified) llvm/lib/IR/LLVMContextImpl.cpp (+3-3)
  • (modified) llvm/lib/IR/LLVMContextImpl.h (+1-1)
  • (modified) llvm/lib/IR/Type.cpp (+2-13)
  • (modified) llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp (-3)
  • (modified) llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp (-1)
  • (modified) llvm/lib/Target/X86/X86CallingConv.td (-34)
  • (modified) llvm/lib/Target/X86/X86ISelLowering.cpp (+93-5)
  • (modified) llvm/lib/Target/X86/X86InstCombineIntrinsic.cpp (+5-3)
  • (modified) llvm/lib/Target/X86/X86IntrinsicsInfo.h (+120-1)
  • (modified) llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp (+2-4)
  • (modified) llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp (-7)
  • (modified) llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp (+21-21)
  • (removed) llvm/test/Assembler/x86mmx.ll (-9)
  • (modified) llvm/test/Bitcode/bcanalyzer-types.ll (-6)
  • (modified) llvm/test/Bitcode/compatibility-3.6.ll (+1-1)
  • (modified) llvm/test/Bitcode/compatibility-3.7.ll (+1-1)
  • (modified) llvm/test/Bitcode/compatibility-3.8.ll (+1-1)
  • (modified) llvm/test/Bitcode/compatibility-3.9.ll (+1-1)
  • (modified) llvm/test/Bitcode/compatibility-4.0.ll (+1-1)
  • (modified) llvm/test/Bitcode/compatibility-5.0.ll (+1-1)
  • (modified) llvm/test/Bitcode/compatibility-6.0.ll (+1-1)
  • (modified) llvm/test/Bitcode/compatibility.ll (+1-1)
  • (modified) llvm/test/CodeGen/X86/2008-09-05-sinttofp-2xi32.ll (+20-1)
  • (modified) llvm/test/CodeGen/X86/3dnow-intrinsics.ll (+56-12)
  • (modified) llvm/test/CodeGen/X86/avx-vbroadcast.ll (+2-6)
  • (modified) llvm/test/CodeGen/X86/avx2-vbroadcast.ll (+2-9)
  • (modified) llvm/test/CodeGen/X86/fast-isel-bc.ll (+6-3)
  • (modified) llvm/test/CodeGen/X86/fast-isel-nontemporal.ll (+2-1)
  • (modified) llvm/test/CodeGen/X86/mmx-arg-passing-x86-64.ll (+7-8)
  • (modified) llvm/test/CodeGen/X86/mmx-arg-passing.ll (+6-4)
  • (modified) llvm/test/CodeGen/X86/mmx-arith.ll (+43-30)
  • (modified) llvm/test/CodeGen/X86/mmx-bitcast-fold.ll (+1-1)
  • (modified) llvm/test/CodeGen/X86/mmx-bitcast.ll (+2-2)
  • (modified) llvm/test/CodeGen/X86/mmx-cvt.ll (+14-84)
  • (modified) llvm/test/CodeGen/X86/mmx-fold-load.ll (+87-20)
  • (added) llvm/test/CodeGen/X86/mmx-inlineasm.ll (+20)
  • (modified) llvm/test/CodeGen/X86/mmx-intrinsics.ll (+207-191)
  • (modified) llvm/test/CodeGen/X86/pr23246.ll (+1-1)
  • (modified) llvm/test/CodeGen/X86/pr29222.ll (+4-2)
  • (modified) llvm/test/CodeGen/X86/select-mmx.ll (+13-22)
  • (modified) llvm/test/CodeGen/X86/stack-folding-3dnow.ll (+82-58)
  • (modified) llvm/test/CodeGen/X86/stack-folding-mmx.ll (+288-220)
  • (modified) llvm/test/CodeGen/X86/vec_extract-mmx.ll (+5-6)
  • (modified) llvm/test/CodeGen/X86/vec_insert-7.ll (+1-2)
  • (modified) llvm/test/CodeGen/X86/vec_insert-mmx.ll (+4-4)
  • (modified) llvm/test/Instrumentation/MemorySanitizer/X86/mmx-intrinsics.ll (+841-826)
  • (modified) llvm/test/Instrumentation/MemorySanitizer/vector_arith.ll (+6-6)
  • (modified) llvm/test/Instrumentation/MemorySanitizer/vector_cvt.ll (+3-3)
  • (modified) llvm/test/Instrumentation/MemorySanitizer/vector_pack.ll (+7-8)
  • (modified) llvm/test/Instrumentation/MemorySanitizer/vector_shift.ll (+5-5)
  • (modified) llvm/test/Transforms/InstCombine/X86/x86-movmsk.ll (+2-12)
  • (modified) llvm/test/Transforms/InstCombine/bitcast-vec-canon-inseltpoison.ll (-45)
  • (modified) llvm/test/Transforms/InstCombine/bitcast-vec-canon.ll (-44)
  • (modified) llvm/test/Transforms/InstSimplify/ConstProp/loads.ll (-13)
  • (removed) llvm/test/Transforms/LoopUnroll/X86/mmx.ll (-35)
  • (modified) llvm/test/Transforms/SLPVectorizer/X86/bad_types.ll (-62)
  • (modified) llvm/test/Transforms/SROA/pr57796.ll (+3-3)
  • (modified) llvm/tools/llvm-c-test/echo.cpp (-2)
  • (modified) llvm/tools/llvm-stress/llvm-stress.cpp (+1-7)
  • (modified) llvm/unittests/IR/InstructionsTest.cpp (+3-6)
  • (modified) mlir/docs/Dialects/LLVM.md (-2)
  • (modified) mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h (-1)
  • (modified) mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp (-1)
  • (modified) mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp (-2)
  • (modified) mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp (+1-4)
  • (modified) mlir/lib/Target/LLVMIR/TypeFromLLVM.cpp (-2)
  • (modified) mlir/lib/Target/LLVMIR/TypeToLLVM.cpp (-3)
  • (modified) mlir/test/Dialect/LLVMIR/types.mlir (-2)
  • (modified) mlir/test/Target/LLVMIR/llvmir-types.mlir (-2)
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 6cc0d9485720c..36853098b118d 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -14386,7 +14386,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
   case X86::BI__builtin_ia32_vec_init_v4hi:
   case X86::BI__builtin_ia32_vec_init_v2si:
     return Builder.CreateBitCast(BuildVector(Ops),
-                                 llvm::Type::getX86_MMXTy(getLLVMContext()));
+                                 llvm::FixedVectorType::get(Int64Ty, 1));
   case X86::BI__builtin_ia32_vec_ext_v2si:
   case X86::BI__builtin_ia32_vec_ext_v16qi:
   case X86::BI__builtin_ia32_vec_ext_v8hi:
@@ -15971,7 +15971,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
   // 3DNow!
   case X86::BI__builtin_ia32_pswapdsf:
   case X86::BI__builtin_ia32_pswapdsi: {
-    llvm::Type *MMXTy = llvm::Type::getX86_MMXTy(getLLVMContext());
+    llvm::Type *MMXTy = llvm::FixedVectorType::get(Int64Ty, 1);
     Ops[0] = Builder.CreateBitCast(Ops[0], MMXTy, "cast");
     llvm::Function *F = CGM.getIntrinsic(Intrinsic::x86_3dnowa_pswapd);
     return Builder.CreateCall(F, Ops, "pswapd");
diff --git a/clang/lib/CodeGen/Targets/X86.cpp b/clang/lib/CodeGen/Targets/X86.cpp
index 1dc3172a6bdf9..8913b188f6aec 100644
--- a/clang/lib/CodeGen/Targets/X86.cpp
+++ b/clang/lib/CodeGen/Targets/X86.cpp
@@ -27,19 +27,6 @@ bool IsX86_MMXType(llvm::Type *IRType) {
 static llvm::Type* X86AdjustInlineAsmType(CodeGen::CodeGenFunction &CGF,
                                           StringRef Constraint,
                                           llvm::Type* Ty) {
-  bool IsMMXCons = llvm::StringSwitch<bool>(Constraint)
-                     .Cases("y", "&y", "^Ym", true)
-                     .Default(false);
-  if (IsMMXCons && Ty->isVectorTy()) {
-    if (cast<llvm::VectorType>(Ty)->getPrimitiveSizeInBits().getFixedValue() !=
-        64) {
-      // Invalid MMX constraint
-      return nullptr;
-    }
-
-    return llvm::Type::getX86_MMXTy(CGF.getLLVMContext());
-  }
-
   if (Constraint == "k") {
     llvm::Type *Int1Ty = llvm::Type::getInt1Ty(CGF.getLLVMContext());
     return llvm::FixedVectorType::get(Int1Ty, Ty->getScalarSizeInBits());
diff --git a/clang/test/CodeGen/X86/mmx-inline-asm.c b/clang/test/CodeGen/X86/mmx-inline-asm.c
index 19c24a3a91e14..a0702c7f780d1 100644
--- a/clang/test/CodeGen/X86/mmx-inline-asm.c
+++ b/clang/test/CodeGen/X86/mmx-inline-asm.c
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -emit-llvm -triple i386 -target-feature +mmx %s -o - | FileCheck %s
 #include <mmintrin.h>
 
-// CHECK: { x86_mmx, x86_mmx, x86_mmx, x86_mmx, x86_mmx, x86_mmx, x86_mmx }
+// CHECK: { <1 x i64>, <1 x i64>, <1 x i64>, <1 x i64>, <1 x i64>, <1 x i64>, <1 x i64> }
 
 void foo(long long fill) {
   __m64 vfill = _mm_cvtsi64_m64(fill);
diff --git a/clang/test/CodeGen/asm-inout.c b/clang/test/CodeGen/asm-inout.c
index 1383a421efbc2..6d40451b778d9 100644
--- a/clang/test/CodeGen/asm-inout.c
+++ b/clang/test/CodeGen/asm-inout.c
@@ -38,11 +38,11 @@ int test4(volatile int *addr) {
   return (int)oldval;
 }
 
-// This should have both inputs be of type x86_mmx.
+// This should have both inputs be of type <1 x i64>.
 // CHECK: @test5
 typedef long long __m64 __attribute__((__vector_size__(8)));
 __m64 test5(__m64 __A, __m64 __B) {
-  // CHECK: call x86_mmx asm "pmulhuw $1, $0\0A\09", "=y,y,0,~{dirflag},~{fpsr},~{flags}"(x86_mmx %{{.*}}, x86_mmx %{{.*}})
+  // CHECK: call <1 x i64> asm "pmulhuw $1, $0\0A\09", "=y,y,0,~{dirflag},~{fpsr},~{flags}"(<1 x i64> %{{.*}}, <1 x i64> %{{.*}})
   asm ("pmulhuw %1, %0\n\t" : "+y" (__A) : "y" (__B));
   return __A;
 }
@@ -51,7 +51,7 @@ __m64 test5(__m64 __A, __m64 __B) {
 int test6(void) {
   typedef unsigned char __attribute__((vector_size(8))) _m64u8;
   _m64u8 __attribute__((aligned(16))) Mu8_0, __attribute__((aligned(16))) Mu8_1;
-  // CHECK: call x86_mmx asm "nop", "=y,0,~{dirflag},~{fpsr},~{flags}"(x86_mmx %1)
+  // CHECK: call <8 x i8> asm "nop", "=y,0,~{dirflag},~{fpsr},~{flags}"(<8 x i8> %0)
   asm ("nop" : "=y"(Mu8_1 ) : "0"(Mu8_0 ));
   return 0;
 }
diff --git a/llvm/bindings/ocaml/llvm/llvm.mli b/llvm/bindings/ocaml/llvm/llvm.mli
index c16530d3a70cb..b8a430adf6cf2 100644
--- a/llvm/bindings/ocaml/llvm/llvm.mli
+++ b/llvm/bindings/ocaml/llvm/llvm.mli
@@ -760,10 +760,6 @@ val void_type : llcontext -> lltype
     [llvm::Type::LabelTy]. *)
 val label_type : llcontext -> lltype
 
-(** [x86_mmx_type c] returns the x86 64-bit MMX register type in the
-    context [c]. See [llvm::Type::X86_MMXTy]. *)
-val x86_mmx_type : llcontext -> lltype
-
 (** [type_by_name m name] returns the specified type from the current module
     if it exists.
     See the method [llvm::Module::getTypeByName] *)
diff --git a/llvm/bindings/ocaml/llvm/llvm_ocaml.c b/llvm/bindings/ocaml/llvm/llvm_ocaml.c
index 4ac824cd6a98a..5906f427e6907 100644
--- a/llvm/bindings/ocaml/llvm/llvm_ocaml.c
+++ b/llvm/bindings/ocaml/llvm/llvm_ocaml.c
@@ -686,11 +686,6 @@ value llvm_label_type(value Context) {
   return to_val(LLVMLabelTypeInContext(Context_val(Context)));
 }
 
-/* llcontext -> lltype */
-value llvm_x86_mmx_type(value Context) {
-  return to_val(LLVMX86MMXTypeInContext(Context_val(Context)));
-}
-
 /* llmodule -> string -> lltype option */
 value llvm_type_by_name(value M, value Name) {
   return ptr_to_option(LLVMGetTypeByName(Module_val(M), String_val(Name)));
diff --git a/llvm/include/llvm-c/Core.h b/llvm/include/llvm-c/Core.h
index 9867db4839fe1..1b18f31e3925c 100644
--- a/llvm/include/llvm-c/Core.h
+++ b/llvm/include/llvm-c/Core.h
@@ -146,27 +146,27 @@ typedef enum {
 } LLVMOpcode;
 
 typedef enum {
-  LLVMVoidTypeKind,      /**< type with no size */
-  LLVMHalfTypeKind,      /**< 16 bit floating point type */
-  LLVMFloatTypeKind,     /**< 32 bit floating point type */
-  LLVMDoubleTypeKind,    /**< 64 bit floating point type */
-  LLVMX86_FP80TypeKind,  /**< 80 bit floating point type (X87) */
-  LLVMFP128TypeKind,     /**< 128 bit floating point type (112-bit mantissa)*/
-  LLVMPPC_FP128TypeKind, /**< 128 bit floating point type (two 64-bits) */
-  LLVMLabelTypeKind,     /**< Labels */
-  LLVMIntegerTypeKind,   /**< Arbitrary bit width integers */
-  LLVMFunctionTypeKind,  /**< Functions */
-  LLVMStructTypeKind,    /**< Structures */
-  LLVMArrayTypeKind,     /**< Arrays */
-  LLVMPointerTypeKind,   /**< Pointers */
-  LLVMVectorTypeKind,    /**< Fixed width SIMD vector type */
-  LLVMMetadataTypeKind,  /**< Metadata */
-  LLVMX86_MMXTypeKind,   /**< X86 MMX */
-  LLVMTokenTypeKind,     /**< Tokens */
-  LLVMScalableVectorTypeKind, /**< Scalable SIMD vector type */
-  LLVMBFloatTypeKind,    /**< 16 bit brain floating point type */
-  LLVMX86_AMXTypeKind,   /**< X86 AMX */
-  LLVMTargetExtTypeKind, /**< Target extension type */
+  LLVMVoidTypeKind = 0,     /**< type with no size */
+  LLVMHalfTypeKind = 1,     /**< 16 bit floating point type */
+  LLVMFloatTypeKind = 2,    /**< 32 bit floating point type */
+  LLVMDoubleTypeKind = 3,   /**< 64 bit floating point type */
+  LLVMX86_FP80TypeKind = 4, /**< 80 bit floating point type (X87) */
+  LLVMFP128TypeKind = 5, /**< 128 bit floating point type (112-bit mantissa)*/
+  LLVMPPC_FP128TypeKind = 6, /**< 128 bit floating point type (two 64-bits) */
+  LLVMLabelTypeKind = 7,     /**< Labels */
+  LLVMIntegerTypeKind = 8,   /**< Arbitrary bit width integers */
+  LLVMFunctionTypeKind = 9,  /**< Functions */
+  LLVMStructTypeKind = 10,   /**< Structures */
+  LLVMArrayTypeKind = 11,    /**< Arrays */
+  LLVMPointerTypeKind = 12,  /**< Pointers */
+  LLVMVectorTypeKind = 13,   /**< Fixed width SIMD vector type */
+  LLVMMetadataTypeKind = 14, /**< Metadata */
+                             /* 15 previously used by LLVMX86_MMXTypeKind */
+  LLVMTokenTypeKind = 16,    /**< Tokens */
+  LLVMScalableVectorTypeKind = 17, /**< Scalable SIMD vector type */
+  LLVMBFloatTypeKind = 18,         /**< 16 bit brain floating point type */
+  LLVMX86_AMXTypeKind = 19,        /**< X86 AMX */
+  LLVMTargetExtTypeKind = 20,      /**< Target extension type */
 } LLVMTypeKind;
 
 typedef enum {
@@ -1672,11 +1672,6 @@ LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C);
  */
 LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C);
 
-/**
- * Create a X86 MMX type in a context.
- */
-LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C);
-
 /**
  * Create a X86 AMX type in a context.
  */
@@ -1698,7 +1693,6 @@ LLVMTypeRef LLVMMetadataTypeInContext(LLVMContextRef C);
  */
 LLVMTypeRef LLVMVoidType(void);
 LLVMTypeRef LLVMLabelType(void);
-LLVMTypeRef LLVMX86MMXType(void);
 LLVMTypeRef LLVMX86AMXType(void);
 
 /**
diff --git a/llvm/include/llvm/IR/DataLayout.h b/llvm/include/llvm/IR/DataLayout.h
index d14adfe1590be..5f7034b5ee36f 100644
--- a/llvm/include/llvm/IR/DataLayout.h
+++ b/llvm/include/llvm/IR/DataLayout.h
@@ -693,7 +693,6 @@ inline TypeSize DataLayout::getTypeSizeInBits(Type *Ty) const {
   case Type::FloatTyID:
     return TypeSize::getFixed(32);
   case Type::DoubleTyID:
-  case Type::X86_MMXTyID:
     return TypeSize::getFixed(64);
   case Type::PPC_FP128TyID:
   case Type::FP128TyID:
diff --git a/llvm/include/llvm/IR/Type.h b/llvm/include/llvm/IR/Type.h
index 1f0133c08e7d6..c74f9e9d24800 100644
--- a/llvm/include/llvm/IR/Type.h
+++ b/llvm/include/llvm/IR/Type.h
@@ -63,7 +63,6 @@ class Type {
     VoidTyID,      ///< type with no size
     LabelTyID,     ///< Labels
     MetadataTyID,  ///< Metadata
-    X86_MMXTyID,   ///< MMX vectors (64 bits, X86 specific)
     X86_AMXTyID,   ///< AMX vectors (8192 bits, X86 specific)
     TokenTyID,     ///< Tokens
 
@@ -197,9 +196,6 @@ class Type {
 
   const fltSemantics &getFltSemantics() const;
 
-  /// Return true if this is X86 MMX.
-  bool isX86_MMXTy() const { return getTypeID() == X86_MMXTyID; }
-
   /// Return true if this is X86 AMX.
   bool isX86_AMXTy() const { return getTypeID() == X86_AMXTyID; }
 
@@ -285,8 +281,8 @@ class Type {
   /// Return true if the type is a valid type for a register in codegen. This
   /// includes all first-class types except struct and array types.
   bool isSingleValueType() const {
-    return isFloatingPointTy() || isX86_MMXTy() || isIntegerTy() ||
-           isPointerTy() || isVectorTy() || isX86_AMXTy() || isTargetExtTy();
+    return isFloatingPointTy() || isIntegerTy() || isPointerTy() ||
+           isVectorTy() || isX86_AMXTy() || isTargetExtTy();
   }
 
   /// Return true if the type is an aggregate type. This means it is valid as
@@ -302,8 +298,7 @@ class Type {
   bool isSized(SmallPtrSetImpl<Type*> *Visited = nullptr) const {
     // If it's a primitive, it is always sized.
     if (getTypeID() == IntegerTyID || isFloatingPointTy() ||
-        getTypeID() == PointerTyID || getTypeID() == X86_MMXTyID ||
-        getTypeID() == X86_AMXTyID)
+        getTypeID() == PointerTyID || getTypeID() == X86_AMXTyID)
       return true;
     // If it is not something that can have a size (e.g. a function or label),
     // it doesn't have a size.
@@ -453,7 +448,6 @@ class Type {
   static Type *getX86_FP80Ty(LLVMContext &C);
   static Type *getFP128Ty(LLVMContext &C);
   static Type *getPPC_FP128Ty(LLVMContext &C);
-  static Type *getX86_MMXTy(LLVMContext &C);
   static Type *getX86_AMXTy(LLVMContext &C);
   static Type *getTokenTy(LLVMContext &C);
   static IntegerType *getIntNTy(LLVMContext &C, unsigned N);
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 962880f68f076..0dbe85631df04 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -564,16 +564,14 @@ Constant *FoldReinterpretLoadFromConst(Constant *C, Type *LoadTy,
     Type *MapTy = Type::getIntNTy(C->getContext(),
                                   DL.getTypeSizeInBits(LoadTy).getFixedValue());
     if (Constant *Res = FoldReinterpretLoadFromConst(C, MapTy, Offset, DL)) {
-      if (Res->isNullValue() && !LoadTy->isX86_MMXTy() &&
-          !LoadTy->isX86_AMXTy())
+      if (Res->isNullValue() && !LoadTy->isX86_AMXTy())
         // Materializing a zero can be done trivially without a bitcast
         return Constant::getNullValue(LoadTy);
       Type *CastTy = LoadTy->isPtrOrPtrVectorTy() ? DL.getIntPtrType(LoadTy) : LoadTy;
       Res = FoldBitCast(Res, CastTy, DL);
       if (LoadTy->isPtrOrPtrVectorTy()) {
         // For vector of pointer, we needed to first convert to a vector of integer, then do vector inttoptr
-        if (Res->isNullValue() && !LoadTy->isX86_MMXTy() &&
-            !LoadTy->isX86_AMXTy())
+        if (Res->isNullValue() && !LoadTy->isX86_AMXTy())
           return Constant::getNullValue(LoadTy);
         if (DL.isNonIntegralPointerType(LoadTy->getScalarType()))
           // Be careful not to replace a load of an addrspace value with an inttoptr here
@@ -764,7 +762,7 @@ Constant *llvm::ConstantFoldLoadFromUniformValue(Constant *C, Type *Ty,
   // uniform.
   if (!DL.typeSizeEqualsStoreSize(C->getType()))
     return nullptr;
-  if (C->isNullValue() && !Ty->isX86_MMXTy() && !Ty->isX86_AMXTy())
+  if (C->isNullValue() && !Ty->isX86_AMXTy())
     return Constant::getNullValue(Ty);
   if (C->isAllOnesValue() &&
       (Ty->isIntOrIntVectorTy() || Ty->isFPOrFPVectorTy()))
diff --git a/llvm/lib/AsmParser/LLLexer.cpp b/llvm/lib/AsmParser/LLLexer.cpp
index 7d7fe19568e8a..c82e74972b67c 100644
--- a/llvm/lib/AsmParser/LLLexer.cpp
+++ b/llvm/lib/AsmParser/LLLexer.cpp
@@ -838,7 +838,8 @@ lltok::Kind LLLexer::LexIdentifier() {
   TYPEKEYWORD("ppc_fp128", Type::getPPC_FP128Ty(Context));
   TYPEKEYWORD("label",     Type::getLabelTy(Context));
   TYPEKEYWORD("metadata",  Type::getMetadataTy(Context));
-  TYPEKEYWORD("x86_mmx",   Type::getX86_MMXTy(Context));
+  TYPEKEYWORD("x86_mmx", llvm::FixedVectorType::get(
+                             llvm::IntegerType::get(Context, 64), 1));
   TYPEKEYWORD("x86_amx",   Type::getX86_AMXTy(Context));
   TYPEKEYWORD("token",     Type::getTokenTy(Context));
   TYPEKEYWORD("ptr",       PointerType::getUnqual(Context));
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index f56b2b32ff98f..7c9bc66a237d5 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -2496,7 +2496,9 @@ Error BitcodeReader::parseTypeTableBody() {
       ResultTy = Type::getMetadataTy(Context);
       break;
     case bitc::TYPE_CODE_X86_MMX:   // X86_MMX
-      ResultTy = Type::getX86_MMXTy(Context);
+      // Deprecated: decodes as <1 x i64>
+      ResultTy =
+          llvm::FixedVectorType::get(llvm::IntegerType::get(Context, 64), 1);
       break;
     case bitc::TYPE_CODE_X86_AMX:   // X86_AMX
       ResultTy = Type::getX86_AMXTy(Context);
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index 3378931065f9b..216a0cc8e94e3 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -1086,8 +1086,9 @@ void ModuleBitcodeWriter::writeTypeTable() {
     case Type::FP128TyID:     Code = bitc::TYPE_CODE_FP128;     break;
     case Type::PPC_FP128TyID: Code = bitc::TYPE_CODE_PPC_FP128; break;
     case Type::LabelTyID:     Code = bitc::TYPE_CODE_LABEL;     break;
-    case Type::MetadataTyID:  Code = bitc::TYPE_CODE_METADATA;  break;
-    case Type::X86_MMXTyID:   Code = bitc::TYPE_CODE_X86_MMX;   break;
+    case Type::MetadataTyID:
+      Code = bitc::TYPE_CODE_METADATA;
+      break;
     case Type::X86_AMXTyID:   Code = bitc::TYPE_CODE_X86_AMX;   break;
     case Type::TokenTyID:     Code = bitc::TYPE_CODE_TOKEN;     break;
     case Type::IntegerTyID:
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 276d980c1dcca..b19047e03b149 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -5225,6 +5225,7 @@ void SelectionDAGBuilder::visitTargetIntrinsic(const CallInst &I,
   // Ignore the callsite's attributes. A specific call site may be marked with
   // readnone, but the lowering code will expect the chain based on the
   // definition.
+  const auto &Triple = DAG.getTarget().getTargetTriple();
   const Function *F = I.getCalledFunction();
   bool HasChain = !F->doesNotAccessMemory();
   bool OnlyLoad = HasChain && F->onlyReadsMemory();
diff --git a/llvm/lib/CodeGen/ValueTypes.cpp b/llvm/lib/CodeGen/ValueTypes.cpp
index b0f736a49c20e..0c6b726a28a24 100644
--- a/llvm/lib/CodeGen/ValueTypes.cpp
+++ b/llvm/lib/CodeGen/ValueTypes.cpp
@@ -207,7 +207,7 @@ Type *EVT::getTypeForEVT(LLVMContext &Context) const {
     assert(isExtended() && "Type is not extended!");
     return LLVMTy;
   case MVT::isVoid:  return Type::getVoidTy(Context);
-  case MVT::x86mmx:  return Type::getX86_MMXTy(Context);
+  case MVT::x86mmx:  return llvm::FixedVectorType::get(llvm::IntegerType::get(Context, 64), 1);
   case MVT::aarch64svcount:
     return TargetExtType::get(Context, "aarch64.svcount");
   case MVT::x86amx:  return Type::getX86_AMXTy(Context);
@@ -241,8 +241,8 @@ MVT MVT::getVT(Type *Ty, bool HandleUnknown){
   case Type::BFloatTyID:    return MVT(MVT::bf16);
   case Type::FloatTyID:     return MVT(MVT::f32);
   case Type::DoubleTyID:    return MVT(MVT::f64);
-  case Type::X86_FP80TyID:  return MVT(MVT::f80);
-  case Type::X86_MMXTyID:   return MVT(MVT::x86mmx);
+  case Type::X86_FP80TyID:
+    return MVT(MVT::f80);
   case Type::TargetExtTyID: {
     TargetExtType *TargetExtTy = cast<TargetExtType>(Ty);
     if (TargetExtTy->getName() == "aarch64.svcount")
@@ -302,4 +302,3 @@ void MVT::print(raw_ostream &OS) const {
   else
     OS << EVT(*this).getEVTString();
 }
-
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index 6599730590de6..01a16ccd688f4 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -573,8 +573,9 @@ void TypePrinting::print(Type *Ty, raw_ostream &OS) {
   case Type::FP128TyID:     OS << "fp128"; return;
   case Type::PPC_FP128TyID: OS << "ppc_fp128"; return;
   case Type::LabelTyID:     OS << "label"; return;
-  case Type::MetadataTyID:  OS << "metadata"; return;
-  case Type::X86_MMXTyID:   OS << "x86_mmx"; return;
+  case Type::MetadataTyID:
+    OS << "metadata";
+    return;
   case Type::X86_AMXTyID:   OS << "x86_amx"; return;
   case Type::TokenTyID:     OS << "token"; return;
   case Type::IntegerTyID:
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp
index 693674ae0d06f..05ab0968ef6f3 100644
--- a/llvm/lib/IR/ConstantFold.cpp
+++ b/llvm/lib/IR/ConstantFold.cpp
@@ -142,7 +142,7 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, Constant *V,
     return UndefValue::get(DestTy);
   }
 
-  if (V->isNullValue() && !DestTy->isX86_MMXTy() && !DestTy->isX86_AMXTy() &&
+  if (V->isNullValue() && !DestTy->isX86_AMXTy() &&
       opc != Instruction::AddrSpaceCast)
     return Constant::getNullValue(DestTy);
 
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp
index 9ba7873106043..b28c3ec56827a 100644
--- a/llvm/lib/IR/Core.cpp
+++ b/llvm/lib/IR/Core.cpp
@@ -609,8 +609,6 @@ LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty) {
     return LLVMPointerTypeKind;
   case Type::FixedVectorTyID:
     return LLVMVectorTypeKind;
-  case Type::X86_MMXTyID:
-    return LLVMX86_MMXTypeKind;
   case Type::X86_AMXTyID:
     return LLVMX86_AMXTypeKind;
   case Type::TokenTyID:
@@ -725,9 +723,6 @@ LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C) {
 LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C) {
   return (LLVMTypeRef) Type::getPPC_FP128Ty(*unwrap(C));
 }
-LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C) {
-  return (LLVMTypeRef) Type::getX86_MMXTy(*unwrap(C));
-}
 LLVMTypeRef LLVMX86AMXTypeInContext(LLVMContextRef C) {
   return (LLVMTypeRef) Type::getX86_AMXTy(*unwrap(C));
 }
@@ -753,9 +748,6 @@ LLVMTypeRef LLVMFP128Type(void) {
 LLVMTypeRef LLVMPPCFP128Type(void) {
   return LLVMPPCFP128TypeInContext(LLVMGetGlobalContext());
 }
-LLVMTypeRef LLVMX86MMXType(void) {
-  return LLVMX86MMXTypeInContext(LLVMGetGlobalContext());
-}
 LLVMTypeRef LLVMX86AMXType(void) {
   return LLVMX86AMXTypeInContext(LLVMGetGlobalContext());
 }
diff --git a/llvm/lib/IR/DataLayout.cpp b/llvm/lib/IR/DataLayout.cpp
index 2741165332487..17897f77b4edb 100644
--- a/llvm/lib/IR/DataLayout.cpp
+++ b/llvm/lib/IR/DataLayout.cpp
@@ -835,7 +8...
[truncated]

Copy link

github-actions bot commented Jul 11, 2024

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff e09032f7a36ffb5eb8638a3933aeca7015a9579a fb399ebe3359597722f1dd6b0914f6e6af737546 --extensions c,h,cpp -- clang/lib/CodeGen/CGBuiltin.cpp clang/lib/CodeGen/Targets/X86.cpp clang/test/CodeGen/X86/mmx-inline-asm.c clang/test/CodeGen/asm-inout.c llvm/bindings/ocaml/llvm/llvm_ocaml.c llvm/include/llvm-c/Core.h llvm/include/llvm/IR/DataLayout.h llvm/include/llvm/IR/Type.h llvm/lib/Analysis/ConstantFolding.cpp llvm/lib/AsmParser/LLLexer.cpp llvm/lib/Bitcode/Reader/BitcodeReader.cpp llvm/lib/Bitcode/Writer/BitcodeWriter.cpp llvm/lib/CodeGen/ValueTypes.cpp llvm/lib/IR/AsmWriter.cpp llvm/lib/IR/ConstantFold.cpp llvm/lib/IR/Core.cpp llvm/lib/IR/DataLayout.cpp llvm/lib/IR/Function.cpp llvm/lib/IR/Instructions.cpp llvm/lib/IR/LLVMContextImpl.cpp llvm/lib/IR/LLVMContextImpl.h llvm/lib/IR/Type.cpp llvm/lib/Target/DirectX/DXILWriter/DXILBitcodeWriter.cpp llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp llvm/lib/Target/X86/X86ISelLowering.cpp llvm/lib/Target/X86/X86InstCombineIntrinsic.cpp llvm/lib/Target/X86/X86IntrinsicsInfo.h llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp llvm/tools/llvm-c-test/echo.cpp llvm/tools/llvm-stress/llvm-stress.cpp llvm/unittests/IR/InstructionsTest.cpp mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp mlir/lib/Dialect/LLVMIR/IR/LLVMTypeSyntax.cpp mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp mlir/lib/Target/LLVMIR/TypeFromLLVM.cpp mlir/lib/Target/LLVMIR/TypeToLLVM.cpp
View the diff from clang-format here.
diff --git a/llvm/lib/IR/Type.cpp b/llvm/lib/IR/Type.cpp
index 9ddccce7f9..18a547e75f 100644
--- a/llvm/lib/IR/Type.cpp
+++ b/llvm/lib/IR/Type.cpp
@@ -44,7 +44,8 @@ Type *Type::getPrimitiveType(LLVMContext &C, TypeID IDNumber) {
   case FP128TyID     : return getFP128Ty(C);
   case PPC_FP128TyID : return getPPC_FP128Ty(C);
   case LabelTyID     : return getLabelTy(C);
-  case MetadataTyID  : return getMetadataTy(C);
+  case MetadataTyID:
+    return getMetadataTy(C);
   case X86_AMXTyID   : return getX86_AMXTy(C);
   case TokenTyID     : return getTokenTy(C);
   default:

@RKSimon RKSimon requested review from RKSimon and phoebewang July 12, 2024 08:34
@@ -57594,6 +57599,86 @@ static SDValue combinePDEP(SDNode *N, SelectionDAG &DAG,
return SDValue();
}

// Fixup the MMX intrinsics' types: in IR they are expressed with <1 x i64>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we able to do it in DAGtoDAG?

Copy link
Member Author

Choose a reason for hiding this comment

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

No -- the problem is that DAGtoDAG is after LegalizeTypes, and v1i64 is not a legal type. LegalizeTypes can't do anything to legalize the vector type arg to an intrinsic, so we need to fix the operand/result types of the intrinsic first, before LegalizeTypes sees it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use i64 instead of <1 x i64> given we don't care about the ABI?

Copy link
Member Author

Choose a reason for hiding this comment

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

We perhaps could use i64, but i64 is also not a legal type on 32bit x86, so I don't think that would actually help here.

I chose <1 x i64> mainly because that's what Clang was already using for MMX values.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right. I forgot the 32bit case.

@@ -38,11 +38,11 @@ int test4(volatile int *addr) {
return (int)oldval;
}

// This should have both inputs be of type x86_mmx.
// This should have both inputs be of type <1 x i64>.
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it conflict with comment in mmx-inlineasm.ll

Verify that the mmx 'y' constraint works with arbitrary IR types.

Copy link
Member Author

Choose a reason for hiding this comment

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

No conflict, although the comment doesn't really have any value now. Since Clang's __m64 is naturally just <1 x i64>, that's not particularly worthy of comment.

Note below there's a case of a <8 x i8> vector passed to a 'y' constraint.

Comment on lines 47 to 48
case MetadataTyID:
return getMetadataTy(C);
Copy link
Contributor

Choose a reason for hiding this comment

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

Keep the old format.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's just what clang-format chose to do. If I modify it back and run clang-format again, it puts it back like this, again.

It'd be great if the whole codebase got clang-formatted so changes to neighboring code like this didn't happen (because all of the case clauses would already be formatted like this), but in the meantime, I think it's better to just go with what the formatter says, unless it causes a lot of noise or is egregiously wrong.

; RUN: verify-uselistorder %s
; Basic smoke test for x86_mmx type.

; CHECK: define x86_mmx @sh16
Copy link
Contributor

Choose a reason for hiding this comment

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

What will it be after this patch?

Copy link
Member Author

Choose a reason for hiding this comment

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

x86_mmx would be translated to <1 x i64>, like in the other tests. That is:

define <1 x i64> @sh16(<1 x i64> %A) {
  ret <1 x i64> %A
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Why we removed it instead of update?

Copy link
Member Author

Choose a reason for hiding this comment

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

The compatibility* tests already cover bitcode-upgrade, and now the IR text "x86_mmx" is simply a textual-IR parse-time alias for <1 x i64>, so this test isn't really testing anything, anymore.

I expect to remove the textual-IR parse-time alias in subsequent cleanup, too -- the main reason for it right now is just to avoid the noise in test updates at the same time as the real changes.

; Basic smoke test for x86_mmx type.

; CHECK: define x86_mmx @sh16
define x86_mmx @sh16(x86_mmx %A) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd expect this to require movement to a bitcode auto upgrade test (but this also appears to be missing a call test)

;

define void @test_mmx(ptr nocapture %a0, ptr nocapture %a1) {
; ALL-LABEL: test_mmx:
; ALL: # %bb.0: # %entry
; ALL-NEXT: movq (%rdi), %mm0
; ALL-NEXT: psrlq $3, %mm0
; ALL-NEXT: movntq %mm0, (%rsi)
; ALL-NEXT: movq %mm0, (%rsi)
Copy link
Contributor

Choose a reason for hiding this comment

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

The nontemporal not respected?

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct; this already wasn't happening under SDag ISel. Now it also isn't happening under fast ISel.

Copy link
Member Author

Choose a reason for hiding this comment

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

@RKSimon's 25952ec fixed this.

@Dinistro
Copy link
Contributor

The MLIR side is looking good, but I cannot say something about the rest.

@nikic
Copy link
Contributor

nikic commented Jul 23, 2024

19.x has already branched, so it's fine to land this now (for LLVM 20).

RKSimon added a commit that referenced this pull request Jul 23, 2024
As noticed on #98505 - we had fast-isel test but not SDAG
RKSimon added a commit that referenced this pull request Jul 23, 2024
As noticed on #98505 - try to reduce codegen diffs until we're ready to drop MMX entirely
sgundapa pushed a commit to sgundapa/upstream_effort that referenced this pull request Jul 23, 2024
As noticed on llvm#98505 - we had fast-isel test but not SDAG
sgundapa pushed a commit to sgundapa/upstream_effort that referenced this pull request Jul 23, 2024
As noticed on llvm#98505 - try to reduce codegen diffs until we're ready to drop MMX entirely
@jyknight jyknight merged commit dfeb399 into llvm:main Jul 25, 2024
4 of 8 checks passed
@jyknight jyknight deleted the remove-mmx-ir-type branch July 25, 2024 13:19
@kamaub
Copy link
Contributor

kamaub commented Jul 25, 2024

The changes made to the if statement in this PR at: dfeb399#diff-f58c914c06010d2cd2c1359514ce9b8a4170e8c214eb52dd49ef5b17d391950eR2681 causes a new -Werror,-Wunused-but-set-variable when building llvm-project with clang in this buildbot's 2nd stage: https://lab.llvm.org/buildbot/#/builders/168/builds/1450/steps/12/logs/stdio, please resolve this build failure as soon as possible to bring the bot back to green.

@jyknight
Copy link
Member Author

@RKSimon has fixed in abacc52, thanks. Sorry for missing that!

maurer added a commit to maurer/rust that referenced this pull request Jul 25, 2024
maurer added a commit to maurer/rust that referenced this pull request Jul 25, 2024
maurer added a commit to maurer/rust that referenced this pull request Jul 25, 2024
yuxuanchen1997 pushed a commit that referenced this pull request Jul 25, 2024
Summary: As noticed on #98505 - we had fast-isel test but not SDAG

Test Plan: 

Reviewers: 

Subscribers: 

Tasks: 

Tags: 


Differential Revision: https://phabricator.intern.facebook.com/D60251072
yuxuanchen1997 pushed a commit that referenced this pull request Jul 25, 2024
Summary: As noticed on #98505 - try to reduce codegen diffs until we're ready to drop MMX entirely

Test Plan: 

Reviewers: 

Subscribers: 

Tasks: 

Tags: 


Differential Revision: https://phabricator.intern.facebook.com/D60251430
yuxuanchen1997 pushed a commit that referenced this pull request Jul 25, 2024
Summary:
It is now translated to `<1 x i64>`, which allows the removal of a bunch
of special casing.

This _incompatibly_ changes the ABI of any LLVM IR function with
`x86_mmx` arguments or returns: instead of passing in mmx registers,
they will now be passed via integer registers. However, the real-world
incompatibility caused by this is expected to be minimal, because Clang
never uses the x86_mmx type -- it lowers `__m64` to either `<1 x i64>`
or `double`, depending on ABI.

This change does _not_ eliminate the SelectionDAG `MVT::x86mmx` type.
That type simply no longer corresponds to an IR type, and is used only
by MMX intrinsics and inline-asm operands.

Because SelectionDAGBuilder only knows how to generate the
operands/results of intrinsics based on the IR type, it thus now
generates the intrinsics with the type MVT::v1i64, instead of
MVT::x86mmx. We need to fix this before the DAG LegalizeTypes, and thus
have the X86 backend fix them up in DAGCombine. (This may be a
short-lived hack, if all the MMX intrinsics can be removed in upcoming
changes.)

Works towards issue #98272.

Test Plan: 

Reviewers: 

Subscribers: 

Tasks: 

Tags: 


Differential Revision: https://phabricator.intern.facebook.com/D60250667
Sisyph added a commit to Sisyph/llvm-dialects that referenced this pull request Jul 25, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jul 25, 2024
LLVM: LLVM-20.0 removes MMX types

See llvm/llvm-project#98505

`@rustbot` label: +llvm-main
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jul 26, 2024
Rollup merge of rust-lang#128194 - maurer:fix-mmx, r=cuviper

LLVM: LLVM-20.0 removes MMX types

See llvm/llvm-project#98505

`@rustbot` label: +llvm-main
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Jul 26, 2024
LLVM: LLVM-20.0 removes MMX types

See llvm/llvm-project#98505

`@rustbot` label: +llvm-main
dstutt pushed a commit to GPUOpen-Drivers/llvm-dialects that referenced this pull request Jul 26, 2024
jyknight added a commit that referenced this pull request Jul 28, 2024
After #98505, the textual IR keyword `x86_mmx` was temporarily made to
parse as `<1 x i64>`, so as not to require a lot of test update noise.

This completes the removal of the type, by removing the`x86_mmx` keyword
from the IR parser, and making the (now no-op) test updates via `sed -i
's/\bx86_mmx\b/<1 x i64>/g' $(git grep -l x86_mmx llvm/test/)`.
Resulting bitcasts from <1 x i64> to itself were then manually deleted.

Changes to llvm/test/Bitcode/compatibility-$VERSION.ll were reverted, as
they're intended to be equivalent to the .bc file, if parsed by old
LLVM, so shouldn't be updated.

A few tests were removed, as they're no longer testing anything, in the
following files:
- llvm/test/Transforms/GlobalOpt/x86_mmx_load.ll
- llvm/test/Transforms/InstCombine/cast.ll
- llvm/test/Transforms/InstSimplify/ConstProp/gep-zeroinit-vector.ll

Works towards issue #98272.
banach-space pushed a commit to banach-space/llvm-project that referenced this pull request Aug 7, 2024
After llvm#98505, the textual IR keyword `x86_mmx` was temporarily made to
parse as `<1 x i64>`, so as not to require a lot of test update noise.

This completes the removal of the type, by removing the`x86_mmx` keyword
from the IR parser, and making the (now no-op) test updates via `sed -i
's/\bx86_mmx\b/<1 x i64>/g' $(git grep -l x86_mmx llvm/test/)`.
Resulting bitcasts from <1 x i64> to itself were then manually deleted.

Changes to llvm/test/Bitcode/compatibility-$VERSION.ll were reverted, as
they're intended to be equivalent to the .bc file, if parsed by old
LLVM, so shouldn't be updated.

A few tests were removed, as they're no longer testing anything, in the
following files:
- llvm/test/Transforms/GlobalOpt/x86_mmx_load.ll
- llvm/test/Transforms/InstCombine/cast.ll
- llvm/test/Transforms/InstSimplify/ConstProp/gep-zeroinit-vector.ll

Works towards issue llvm#98272.
searlmc1 pushed a commit to ROCm/llvm-project that referenced this pull request Aug 22, 2024
Revert: breaks devIO for openmp
dfeb399 Remove the `x86_mmx` IR type. (llvm#98505)

Change-Id: I47a8f453131fccfdd8d72638766b03f66705a7d3
searlmc1 pushed a commit to ROCm/llvm-project that referenced this pull request Nov 9, 2024
cherry-pick:
dfeb399 jyknight@google.com Thu Jul 25 09:19:22 2024 -0400 Remove the `x86_mmx` IR type. (llvm#98505)
b7e4fba jyknight@google.com Sun Jul 28 18:12:47 2024 -0400 Cleanup x86_mmx after removing IR type  (llvm#100646)

Change-Id: I987eda387fc403ab249f9d48eeb13fd66606343a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

8 participants