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

[LLVM][TableGen] Check validity of IIT encoding for vector types #111152

Merged
merged 1 commit into from
Oct 4, 2024

Conversation

jurahul
Copy link
Contributor

@jurahul jurahul commented Oct 4, 2024

Add assert to verify that the IIT_Vecs list for IIT encoding of vector types is not empty for vector types (else it will generate an invalid IIT encoding).

Remove llvm_v2048i1_ty for which this assert fails, since the Intrinsics.td file does not define any IIT encoding for vectors of size 2048.

Add assert to verify that the `IIT_Vecs` list for IIT encoding of
vector types is not empty for vector types (else it will generate
an invalid IIT encoding).

Remove `llvm_v2048i1_ty` for which this assert fails, since the
`Intrinsics.td` file does not define any IIT encoding for vectors
of size 2048.
@jurahul
Copy link
Contributor Author

jurahul commented Oct 4, 2024

With the added assert, I get the following for Intrinsics.td:

./build/bin/llvm-tblgen -I llvm/include/ llvm/include/llvm/IR/Intrinsics.td --time-phases > d
llvm/include/llvm/IR/Intrinsics.td:376:10: error: assertion failed
  assert !or(!not(vt.isVector), !not(!empty(IIT_Vecs))),
         ^
note: Invalid IIT encoding for vector type v2048i1
llvm/include/llvm/IR/Intrinsics.td:525:5: error: assertion failed in this record
def llvm_v2048i1_ty    : LLVMType<v2048i1>;  //2048 x i1

@jurahul jurahul marked this pull request as ready for review October 4, 2024 15:19
@jurahul jurahul requested review from chapuni and arsenm October 4, 2024 15:19
@llvmbot llvmbot added the llvm:ir label Oct 4, 2024
@llvmbot
Copy link
Member

llvmbot commented Oct 4, 2024

@llvm/pr-subscribers-llvm-ir

Author: Rahul Joshi (jurahul)

Changes

Add assert to verify that the IIT_Vecs list for IIT encoding of vector types is not empty for vector types (else it will generate an invalid IIT encoding).

Remove llvm_v2048i1_ty for which this assert fails, since the Intrinsics.td file does not define any IIT encoding for vectors of size 2048.


Full diff: https://github.com/llvm/llvm-project/pull/111152.diff

1 Files Affected:

  • (modified) llvm/include/llvm/IR/Intrinsics.td (+4-1)
diff --git a/llvm/include/llvm/IR/Intrinsics.td b/llvm/include/llvm/IR/Intrinsics.td
index 1e243eb27b312a..20dd921ddbd230 100644
--- a/llvm/include/llvm/IR/Intrinsics.td
+++ b/llvm/include/llvm/IR/Intrinsics.td
@@ -372,6 +372,10 @@ class LLVMType<ValueType vt> {
     []);
   assert !le(!size(IIT_Vecs), 1), "Duplicate type";
 
+  // For vector types, assert that the IIT_Vecs list is not empty.
+  assert !or(!not(vt.isVector), !not(!empty(IIT_Vecs))),
+         "Invalid IIT encoding for vector type v" # vt.nElem # vt.ElementType;
+
   list<int> Sig = !listconcat(
     !if(vt.isScalable, [IIT_SCALABLE_VEC.Number], []),
     !foreach(iit, IIT_Vecs, iit.Number),
@@ -518,7 +522,6 @@ def llvm_v128i1_ty     : LLVMType<v128i1>;   // 128 x i1
 def llvm_v256i1_ty     : LLVMType<v256i1>;   // 256 x i1
 def llvm_v512i1_ty     : LLVMType<v512i1>;   // 512 x i1
 def llvm_v1024i1_ty    : LLVMType<v1024i1>;  //1024 x i1
-def llvm_v2048i1_ty    : LLVMType<v2048i1>;  //2048 x i1
 
 def llvm_v1i8_ty       : LLVMType<v1i8>;     //  1 x i8
 def llvm_v2i8_ty       : LLVMType<v2i8>;     //  2 x i8

@jurahul jurahul merged commit ed0f407 into llvm:main Oct 4, 2024
13 checks passed
@jurahul jurahul deleted the iit_encoding_vec_type_assert branch October 4, 2024 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants