-
Notifications
You must be signed in to change notification settings - Fork 15.5k
[CIR][CIRGen][Builtin][X86] Compress Store Intrinsics #169648
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
base: main
Are you sure you want to change the base?
Conversation
This is my first commit. Requesting reviews.
|
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
|
@llvm/pr-subscribers-clangir Author: AnkitDubeycs25 (AnkitDubeycs25) ChangesThis is my first commit. Requesting reviews. Full diff: https://github.com/llvm/llvm-project/pull/169648.diff 2 Files Affected:
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp b/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
index e7aa8a234efd9..5c3e7f7512851 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
@@ -90,6 +90,14 @@ static mlir::Value getMaskVecValue(CIRGenFunction &cgf, const CallExpr *expr,
return maskVec;
}
+static mlir::Value emitX86CompressStore(CIRGenFunction &cgf, const CallExpr *expr, ArrayRef<mlir::Value> ops){
+ auto ResultTy = cast<cir::VectorType>(ops[1].getType());
+ mlir::Value MaskValue = getMaskVecValue(cgf, expr, ops[2], cast<cir::VectorType>(ResultTy).getSize());
+ mlir::Value ptr = ops[0];
+
+ return emitIntrinsicCallOp(cgf, expr, "masked_compressstore", ResultTy, llvm::SmallVector<mlir::Value, 3>{ops[1], ptr, MaskValue});
+
+}
mlir::Value CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID,
const CallExpr *expr) {
if (builtinID == Builtin::BI__builtin_cpu_is) {
@@ -400,7 +408,12 @@ mlir::Value CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID,
case X86::BI__builtin_ia32_expandloadhi512_mask:
case X86::BI__builtin_ia32_expandloadqi128_mask:
case X86::BI__builtin_ia32_expandloadqi256_mask:
- case X86::BI__builtin_ia32_expandloadqi512_mask:
+ case X86::BI__builtin_ia32_expandloadqi512_mask:{
+ cgm.errorNYI(expr->getSourceRange(),
+ std::string("unimplemented X86 builtin call: ") +
+ getContext().BuiltinInfo.getName(builtinID));
+ return {};
+ }
case X86::BI__builtin_ia32_compressstoredf128_mask:
case X86::BI__builtin_ia32_compressstoredf256_mask:
case X86::BI__builtin_ia32_compressstoredf512_mask:
@@ -419,6 +432,7 @@ mlir::Value CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID,
case X86::BI__builtin_ia32_compressstoreqi128_mask:
case X86::BI__builtin_ia32_compressstoreqi256_mask:
case X86::BI__builtin_ia32_compressstoreqi512_mask:
+ return emitX86CompressStore(*this, expr, ops);
case X86::BI__builtin_ia32_expanddf128_mask:
case X86::BI__builtin_ia32_expanddf256_mask:
case X86::BI__builtin_ia32_expanddf512_mask:
diff --git a/clang/test/CIR/CodeGen/X86/compressStore_builtin.c b/clang/test/CIR/CodeGen/X86/compressStore_builtin.c
new file mode 100644
index 0000000000000..1407e21428aee
--- /dev/null
+++ b/clang/test/CIR/CodeGen/X86/compressStore_builtin.c
@@ -0,0 +1,5 @@
+#include <immintrin.h>
+
+void test_compress_store(void *__P, __mmask8 __U, __m128d __A){
+ return _mm_mask_compressstoreu_pd (__P, __U, __A);
+}
\ No newline at end of file
|
|
@llvm/pr-subscribers-clang Author: AnkitDubeycs25 (AnkitDubeycs25) ChangesThis is my first commit. Requesting reviews. Full diff: https://github.com/llvm/llvm-project/pull/169648.diff 2 Files Affected:
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp b/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
index e7aa8a234efd9..5c3e7f7512851 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
@@ -90,6 +90,14 @@ static mlir::Value getMaskVecValue(CIRGenFunction &cgf, const CallExpr *expr,
return maskVec;
}
+static mlir::Value emitX86CompressStore(CIRGenFunction &cgf, const CallExpr *expr, ArrayRef<mlir::Value> ops){
+ auto ResultTy = cast<cir::VectorType>(ops[1].getType());
+ mlir::Value MaskValue = getMaskVecValue(cgf, expr, ops[2], cast<cir::VectorType>(ResultTy).getSize());
+ mlir::Value ptr = ops[0];
+
+ return emitIntrinsicCallOp(cgf, expr, "masked_compressstore", ResultTy, llvm::SmallVector<mlir::Value, 3>{ops[1], ptr, MaskValue});
+
+}
mlir::Value CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID,
const CallExpr *expr) {
if (builtinID == Builtin::BI__builtin_cpu_is) {
@@ -400,7 +408,12 @@ mlir::Value CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID,
case X86::BI__builtin_ia32_expandloadhi512_mask:
case X86::BI__builtin_ia32_expandloadqi128_mask:
case X86::BI__builtin_ia32_expandloadqi256_mask:
- case X86::BI__builtin_ia32_expandloadqi512_mask:
+ case X86::BI__builtin_ia32_expandloadqi512_mask:{
+ cgm.errorNYI(expr->getSourceRange(),
+ std::string("unimplemented X86 builtin call: ") +
+ getContext().BuiltinInfo.getName(builtinID));
+ return {};
+ }
case X86::BI__builtin_ia32_compressstoredf128_mask:
case X86::BI__builtin_ia32_compressstoredf256_mask:
case X86::BI__builtin_ia32_compressstoredf512_mask:
@@ -419,6 +432,7 @@ mlir::Value CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID,
case X86::BI__builtin_ia32_compressstoreqi128_mask:
case X86::BI__builtin_ia32_compressstoreqi256_mask:
case X86::BI__builtin_ia32_compressstoreqi512_mask:
+ return emitX86CompressStore(*this, expr, ops);
case X86::BI__builtin_ia32_expanddf128_mask:
case X86::BI__builtin_ia32_expanddf256_mask:
case X86::BI__builtin_ia32_expanddf512_mask:
diff --git a/clang/test/CIR/CodeGen/X86/compressStore_builtin.c b/clang/test/CIR/CodeGen/X86/compressStore_builtin.c
new file mode 100644
index 0000000000000..1407e21428aee
--- /dev/null
+++ b/clang/test/CIR/CodeGen/X86/compressStore_builtin.c
@@ -0,0 +1,5 @@
+#include <immintrin.h>
+
+void test_compress_store(void *__P, __mmask8 __U, __m128d __A){
+ return _mm_mask_compressstoreu_pd (__P, __U, __A);
+}
\ No newline at end of file
|
andykaylor
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the patch! I have a few requests for changes.
| @@ -0,0 +1,5 @@ | |||
| #include <immintrin.h> | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test should be moved to clang/test/CIR/CodeGenBuiltins/X86/avx512vl-builtins.c which is also being added in #169582. The test will need RUN lines and CIR, LLVM, and OGCG checks added.
| mlir::Value MaskValue = getMaskVecValue(cgf, expr, ops[2], cast<cir::VectorType>(ResultTy).getSize()); | ||
| mlir::Value ptr = ops[0]; | ||
|
|
||
| return emitIntrinsicCallOp(cgf, expr, "masked_compressstore", ResultTy, llvm::SmallVector<mlir::Value, 3>{ops[1], ptr, MaskValue}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| return emitIntrinsicCallOp(cgf, expr, "masked_compressstore", ResultTy, llvm::SmallVector<mlir::Value, 3>{ops[1], ptr, MaskValue}); | |
| return emitIntrinsicCallOp(builder, loc, "masked_compressstore", ResultTy, mlir::ValueRange{ops[1], ptr, MaskValue}); |
| return maskVec; | ||
| } | ||
|
|
||
| static mlir::Value emitX86CompressStore(CIRGenFunction &cgf, const CallExpr *expr, ArrayRef<mlir::Value> ops){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| static mlir::Value emitX86CompressStore(CIRGenFunction &cgf, const CallExpr *expr, ArrayRef<mlir::Value> ops){ | |
| static mlir::Value emitX86CompressStore(CIRGenBuilderTy &builder, mlir::Location loc, ArrayRef<mlir::Value> ops){ |
The signature of emitIntrinsicCallOp has recently been updated. This change makes the function you are adding consistent with it.
| case X86::BI__builtin_ia32_compressstoreqi128_mask: | ||
| case X86::BI__builtin_ia32_compressstoreqi256_mask: | ||
| case X86::BI__builtin_ia32_compressstoreqi512_mask: | ||
| return emitX86CompressStore(*this, expr, ops); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| return emitX86CompressStore(*this, expr, ops); | |
| return emitX86CompressStore(builder, getLoc(expr->getExprLoc()), ops); |
You can test this locally with the following command:git-clang-format --diff origin/main HEAD --extensions cpp,c -- clang/test/CIR/CodeGen/X86/compressStore_builtin.c clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp --diff_from_common_commit
View the diff from clang-format here.diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp b/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
index 5c3e7f751..d45ee7e90 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
@@ -90,13 +90,17 @@ static mlir::Value getMaskVecValue(CIRGenFunction &cgf, const CallExpr *expr,
return maskVec;
}
-static mlir::Value emitX86CompressStore(CIRGenFunction &cgf, const CallExpr *expr, ArrayRef<mlir::Value> ops){
+static mlir::Value emitX86CompressStore(CIRGenFunction &cgf,
+ const CallExpr *expr,
+ ArrayRef<mlir::Value> ops) {
auto ResultTy = cast<cir::VectorType>(ops[1].getType());
- mlir::Value MaskValue = getMaskVecValue(cgf, expr, ops[2], cast<cir::VectorType>(ResultTy).getSize());
+ mlir::Value MaskValue = getMaskVecValue(
+ cgf, expr, ops[2], cast<cir::VectorType>(ResultTy).getSize());
mlir::Value ptr = ops[0];
- return emitIntrinsicCallOp(cgf, expr, "masked_compressstore", ResultTy, llvm::SmallVector<mlir::Value, 3>{ops[1], ptr, MaskValue});
-
+ return emitIntrinsicCallOp(
+ cgf, expr, "masked_compressstore", ResultTy,
+ llvm::SmallVector<mlir::Value, 3>{ops[1], ptr, MaskValue});
}
mlir::Value CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID,
const CallExpr *expr) {
@@ -408,7 +412,7 @@ mlir::Value CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID,
case X86::BI__builtin_ia32_expandloadhi512_mask:
case X86::BI__builtin_ia32_expandloadqi128_mask:
case X86::BI__builtin_ia32_expandloadqi256_mask:
- case X86::BI__builtin_ia32_expandloadqi512_mask:{
+ case X86::BI__builtin_ia32_expandloadqi512_mask: {
cgm.errorNYI(expr->getSourceRange(),
std::string("unimplemented X86 builtin call: ") +
getContext().BuiltinInfo.getName(builtinID));
|
🐧 Linux x64 Test Results
All tests passed but another part of the build failed. Click on a failure below to see the details. tools/clang/lib/CIR/CodeGen/CMakeFiles/obj.clangCIR.dir/CIRGenAtomic.cpp.oIf these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the |
This is my first commit. Requesting reviews.