[llvm] 88e5df0 - [X86] LowerVectorAllEqual - handle i64 comparisons on 32-bit targets
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 1 09:16:49 PDT 2023
Author: Simon Pilgrim
Date: 2023-04-01T17:16:37+01:00
New Revision: 88e5df0e4392cf25a03fc0ac9aa5b8da60079dac
URL: https://github.com/llvm/llvm-project/commit/88e5df0e4392cf25a03fc0ac9aa5b8da60079dac
DIFF: https://github.com/llvm/llvm-project/commit/88e5df0e4392cf25a03fc0ac9aa5b8da60079dac.diff
LOG: [X86] LowerVectorAllEqual - handle i64 comparisons on 32-bit targets
Added:
Modified:
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/pr53419.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 246909bc62c7..84270d5c701f 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -24366,8 +24366,21 @@ static SDValue LowerVectorAllEqual(const SDLoc &DL, SDValue LHS, SDValue RHS,
// For sub-128-bit vector, cast to (legal) integer and compare with zero.
if (VT.getSizeInBits() < 128) {
EVT IntVT = EVT::getIntegerVT(*DAG.getContext(), VT.getSizeInBits());
- if (!DAG.getTargetLoweringInfo().isTypeLegal(IntVT))
- return SDValue();
+ if (!DAG.getTargetLoweringInfo().isTypeLegal(IntVT)) {
+ if (IntVT != MVT::i64)
+ return SDValue();
+ auto SplitLHS = DAG.SplitScalar(DAG.getBitcast(IntVT, MaskBits(LHS)), DL,
+ MVT::i32, MVT::i32);
+ auto SplitRHS = DAG.SplitScalar(DAG.getBitcast(IntVT, MaskBits(RHS)), DL,
+ MVT::i32, MVT::i32);
+ SDValue Lo =
+ DAG.getNode(ISD::XOR, DL, MVT::i32, SplitLHS.first, SplitRHS.first);
+ SDValue Hi =
+ DAG.getNode(ISD::XOR, DL, MVT::i32, SplitLHS.second, SplitRHS.second);
+ return DAG.getNode(X86ISD::CMP, DL, MVT::i32,
+ DAG.getNode(ISD::OR, DL, MVT::i32, Lo, Hi),
+ DAG.getConstant(0, DL, MVT::i32));
+ }
return DAG.getNode(X86ISD::CMP, DL, MVT::i32,
DAG.getBitcast(IntVT, MaskBits(LHS)),
DAG.getBitcast(IntVT, MaskBits(RHS)));
diff --git a/llvm/test/CodeGen/X86/pr53419.ll b/llvm/test/CodeGen/X86/pr53419.ll
index f6369112b99f..db86a69c50b1 100644
--- a/llvm/test/CodeGen/X86/pr53419.ll
+++ b/llvm/test/CodeGen/X86/pr53419.ll
@@ -149,11 +149,11 @@ define i1 @vector_version_v8i8(ptr align 1 %arg, ptr align 1 %arg1) {
; X86: # %bb.0: # %bb
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
-; X86-NEXT: vmovq {{.*#+}} xmm0 = mem[0],zero
-; X86-NEXT: vmovq {{.*#+}} xmm1 = mem[0],zero
-; X86-NEXT: vpcmpeqb %xmm1, %xmm0, %xmm0
-; X86-NEXT: vpmovmskb %xmm0, %eax
-; X86-NEXT: xorb $-1, %al
+; X86-NEXT: movl (%ecx), %edx
+; X86-NEXT: movl 4(%ecx), %ecx
+; X86-NEXT: xorl 4(%eax), %ecx
+; X86-NEXT: xorl (%eax), %edx
+; X86-NEXT: orl %ecx, %edx
; X86-NEXT: sete %al
; X86-NEXT: retl
bb:
More information about the llvm-commits
mailing list