-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[X86][ISel] Fix VPTERNLOG matching ensuring the InnerOp is logicOp #166591
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
Conversation
|
@llvm/pr-subscribers-backend-x86 Author: Yi-Chi Lee (yichi170) ChangesThis patch fixes a crash in Previously, This patch applies A new test is added to reproduce the same crash mentioned in #164863 by @RKSimon . Full diff: https://github.com/llvm/llvm-project/pull/166591.diff 2 Files Affected:
diff --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
index d4418c8563780..6c16fcfb282e8 100644
--- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
+++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
@@ -4728,9 +4728,9 @@ bool X86DAGToDAGISel::tryVPTERNLOG(SDNode *N) {
auto tryPeelOuterNotWrappingLogic = [&](SDNode *Op) {
if (Op->getOpcode() == ISD::XOR && Op->hasOneUse() &&
ISD::isBuildVectorAllOnes(Op->getOperand(1).getNode())) {
- SDValue InnerOp = Op->getOperand(0);
+ SDValue InnerOp = getFoldableLogicOp(Op->getOperand(0));
- if (!getFoldableLogicOp(InnerOp))
+ if (!InnerOp)
return SDValue();
N0 = InnerOp.getOperand(0);
diff --git a/llvm/test/CodeGen/X86/issue163738.ll b/llvm/test/CodeGen/X86/vpternlog.ll
similarity index 59%
rename from llvm/test/CodeGen/X86/issue163738.ll
rename to llvm/test/CodeGen/X86/vpternlog.ll
index 61fe043a970dd..bd7478d3a82d5 100644
--- a/llvm/test/CodeGen/X86/issue163738.ll
+++ b/llvm/test/CodeGen/X86/vpternlog.ll
@@ -11,3 +11,15 @@ define <8 x i64> @foo(<8 x i64> %a, <8 x i64> %b, <8 x i64> %c) {
%and3 = xor <8 x i64> %and3.demorgan, splat (i64 -1)
ret <8 x i64> %and3
}
+
+define <8 x i64> @xorbitcast(<64 x i8> %a, <64 x i8> %b, <64 x i8> %c) {
+; CHECK-LABEL: xorbitcast:
+; CHECK: # %bb.0:
+; CHECK-NEXT: vpternlogq {{.*#+}} zmm0 = ~(zmm0 | zmm2 | zmm1)
+; CHECK-NEXT: retq
+ %or1 = or <64 x i8> %a, %b
+ %or2 = or <64 x i8> %or1, %c
+ %cast = bitcast <64 x i8> %or2 to <8 x i64>
+ %xor = xor <8 x i64> %cast, splat (i64 -1)
+ ret <8 x i64> %xor
+}
|
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 - cheers
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/10/builds/16774 Here is the relevant piece of the build log for the reference |
This patch fixes a crash in
tryVPTERNLOGwhen trying to peel out the outer not in cases like~(A | B | C).Previously,
InnerOpwas taken directly fromOp->getOperand(0)before verifying that it was a logical operation. As a result, the code could later accessInnerOp->getOperand(0)orInnerOp->getOperand(1)even whenInnerOpwas something like a bitcast, causing an error.This patch applies
getFoldableLogicOptoInnerOp, ensuring thatInnerOpis a valid logic operation before it is dereferenced.A simplified test is added to reproduce the same crash mentioned in #164863 by @RKSimon.