[llvm] r352328 - [X86][SSE] Permit UNDEFs in combineAddToSUBUS matching (PR40083)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 27 12:36:37 PST 2019
Author: rksimon
Date: Sun Jan 27 12:36:37 2019
New Revision: 352328
URL: http://llvm.org/viewvc/llvm-project?rev=352328&view=rev
Log:
[X86][SSE] Permit UNDEFs in combineAddToSUBUS matching (PR40083)
Modified:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
llvm/trunk/test/CodeGen/X86/psubus.ll
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=352328&r1=352327&r2=352328&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Sun Jan 27 12:36:37 2019
@@ -41106,11 +41106,12 @@ static SDValue combineAddToSUBUS(SDNode
return SDValue();
// The add should have a constant that is the negative of the max.
- // TODO: Handle build_vectors with undef elements.
auto MatchUSUBSAT = [](ConstantSDNode *Max, ConstantSDNode *Op) {
- return Max->getAPIntValue() == (-Op->getAPIntValue());
+ return (!Max && !Op) ||
+ (Max && Op && Max->getAPIntValue() == (-Op->getAPIntValue()));
};
- if (!ISD::matchBinaryPredicate(Op0.getOperand(1), Op1, MatchUSUBSAT))
+ if (!ISD::matchBinaryPredicate(Op0.getOperand(1), Op1, MatchUSUBSAT,
+ /*AllowUndefs*/ true))
return SDValue();
SDLoc DL(N);
Modified: llvm/trunk/test/CodeGen/X86/psubus.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/psubus.ll?rev=352328&r1=352327&r2=352328&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/psubus.ll (original)
+++ llvm/trunk/test/CodeGen/X86/psubus.ll Sun Jan 27 12:36:37 2019
@@ -2728,37 +2728,15 @@ entry:
; PR40083
define i64 @test30(<8 x i16> %x) {
-; SSE2-LABEL: test30:
-; SSE2: # %bb.0: # %entry
-; SSE2-NEXT: movdqa {{.*#+}} xmm1 = [32768,32768,32768,32768,32768,32768,32768,32768]
-; SSE2-NEXT: pxor %xmm1, %xmm0
-; SSE2-NEXT: pmaxsw {{.*}}(%rip), %xmm0
-; SSE2-NEXT: pxor %xmm1, %xmm0
-; SSE2-NEXT: paddw {{.*}}(%rip), %xmm0
-; SSE2-NEXT: movq %xmm0, %rax
-; SSE2-NEXT: retq
-;
-; SSSE3-LABEL: test30:
-; SSSE3: # %bb.0: # %entry
-; SSSE3-NEXT: movdqa {{.*#+}} xmm1 = [32768,32768,32768,32768,32768,32768,32768,32768]
-; SSSE3-NEXT: pxor %xmm1, %xmm0
-; SSSE3-NEXT: pmaxsw {{.*}}(%rip), %xmm0
-; SSSE3-NEXT: pxor %xmm1, %xmm0
-; SSSE3-NEXT: paddw {{.*}}(%rip), %xmm0
-; SSSE3-NEXT: movq %xmm0, %rax
-; SSSE3-NEXT: retq
-;
-; SSE41-LABEL: test30:
-; SSE41: # %bb.0: # %entry
-; SSE41-NEXT: pmaxuw {{.*}}(%rip), %xmm0
-; SSE41-NEXT: paddw {{.*}}(%rip), %xmm0
-; SSE41-NEXT: movq %xmm0, %rax
-; SSE41-NEXT: retq
+; SSE-LABEL: test30:
+; SSE: # %bb.0: # %entry
+; SSE-NEXT: psubusw {{.*}}(%rip), %xmm0
+; SSE-NEXT: movq %xmm0, %rax
+; SSE-NEXT: retq
;
; AVX-LABEL: test30:
; AVX: # %bb.0: # %entry
-; AVX-NEXT: vpmaxuw {{.*}}(%rip), %xmm0, %xmm0
-; AVX-NEXT: vpaddw {{.*}}(%rip), %xmm0, %xmm0
+; AVX-NEXT: vpsubusw {{.*}}(%rip), %xmm0, %xmm0
; AVX-NEXT: vmovq %xmm0, %rax
; AVX-NEXT: retq
entry:
More information about the llvm-commits
mailing list