-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[DAG] Update canCreateUndefOrPoison to handle ISD::VECTOR_COMPRESS #168010
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
[DAG] Update canCreateUndefOrPoison to handle ISD::VECTOR_COMPRESS #168010
Conversation
|
@llvm/pr-subscribers-backend-x86 @llvm/pr-subscribers-llvm-selectiondag Author: 陈子昂 (Michael-Chen-NJU) ChangesUpdates Fixes #167710 Full diff: https://github.com/llvm/llvm-project/pull/168010.diff 1 Files Affected:
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index c2b4c19846316..38fee7c83e1c0 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -5702,6 +5702,11 @@ bool SelectionDAG::canCreateUndefOrPoison(SDValue Op, const APInt &DemandedElts,
return false;
}
+ case ISD::VECTOR_COMPRESS:
+ // Return true only if undef is checked and at least one element is
+ // demanded.
+ return !PoisonOnly && !DemandedElts.isZero();
+
default:
// Allow the target to implement this method for its nodes.
if (Opcode >= ISD::BUILTIN_OP_END || Opcode == ISD::INTRINSIC_WO_CHAIN ||
|
arsenm
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.
Needs tests
|
@Michael-Chen-NJU You'll probably have to do value tracking style tests: declare <16 x i32> @llvm.experimental.vector.compress.v16i32(<16 x i32>, <16 x i1>, <16 x i32>)
define <16 x i32> @src(<16 x i32> %a0, <16 x i32> %a1, <16 x i8> %a3) {
%cmp = icmp sgt <16 x i32> %a0, %a1
%ext = zext <16 x i8> %a3 to <16 x i32>
%cpr = call <16 x i32> @llvm.experimental.vector.compress.v16i32(<16 x i32> %ext, <16 x i1> %cmp, <16 x i32> splat(i32 15))
%fr = freeze <16 x i32> %cpr
%and = and <16 x i32> %fr, splat (i32 15)
ret <16 x i32> %and
}
define <16 x i32> @tgt(<16 x i32> %a0, <16 x i32> %a1, <16 x i8> %a3) {
%cmp = icmp sgt <16 x i32> %a0, %a1
%ext = zext <16 x i8> %a3 to <16 x i32>
%cpr = call <16 x i32> @llvm.experimental.vector.compress.v16i32(<16 x i32> %ext, <16 x i1> %cmp, <16 x i32> splat(i32 15))
%and = and <16 x i32> %cpr, splat (i32 255)
ret <16 x i32> %and
} |
…s for freeze elimination
|
✅ With the latest revision this PR passed the undef deprecator. |
122d49a to
d67fee9
Compare
…freeze elimination test
🐧 Linux x64 Test Results
|
RKSimon
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.
LGTM
Updates
canCreateUndefOrPoisonto return a precise result for ISD::VECTOR_COMPRESS, correctly reporting that it generates undef (in the tail) but not poison.Fixes #167710