[PATCH] D81212: [X86] Teach combineVectorShiftImm to constant fold undef elements to 0 not undef.
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 5 11:48:05 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7c9a89fed8f5: [X86] Teach combineVectorShiftImm to constant fold undef elements to 0 not… (authored by craig.topper).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D81212/new/
https://reviews.llvm.org/D81212
Files:
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/vec_shift5.ll
Index: llvm/test/CodeGen/X86/vec_shift5.ll
===================================================================
--- llvm/test/CodeGen/X86/vec_shift5.ll
+++ llvm/test/CodeGen/X86/vec_shift5.ll
@@ -149,7 +149,7 @@
define <2 x i64> @test11() {
; X32-LABEL: test11:
; X32: # %bb.0:
-; X32-NEXT: movaps {{.*#+}} xmm0 = <u,u,3,0>
+; X32-NEXT: movaps {{.*#+}} xmm0 = [0,0,3,0]
; X32-NEXT: retl
;
; X64-LABEL: test11:
@@ -219,7 +219,7 @@
define <2 x i64> @test16() {
; X32-LABEL: test16:
; X32: # %bb.0:
-; X32-NEXT: movaps {{.*#+}} xmm0 = <u,u,248,0>
+; X32-NEXT: movaps {{.*#+}} xmm0 = [0,0,248,0]
; X32-NEXT: retl
;
; X64-LABEL: test16:
Index: llvm/lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- llvm/lib/Target/X86/X86ISelLowering.cpp
+++ llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -41439,14 +41439,22 @@
getTargetConstantBitsFromNode(N0, NumBitsPerElt, UndefElts, EltBits)) {
assert(EltBits.size() == VT.getVectorNumElements() &&
"Unexpected shift value type");
- for (APInt &Elt : EltBits) {
- if (X86ISD::VSHLI == Opcode)
+ // Undef elements need to fold to 0. It's possible SimplifyDemandedBits
+ // created an undef input due to no input bits being demanded, but user
+ // still expects 0 in other bits.
+ for (unsigned i = 0, e = EltBits.size(); i != e; ++i) {
+ APInt &Elt = EltBits[i];
+ if (UndefElts[i])
+ Elt = 0;
+ else if (X86ISD::VSHLI == Opcode)
Elt <<= ShiftVal;
else if (X86ISD::VSRAI == Opcode)
Elt.ashrInPlace(ShiftVal);
else
Elt.lshrInPlace(ShiftVal);
}
+ // Reset undef elements since they were zeroed above.
+ UndefElts = 0;
return getConstVector(EltBits, UndefElts, VT.getSimpleVT(), DAG, SDLoc(N));
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81212.268901.patch
Type: text/x-patch
Size: 1850 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200605/6ad475ca/attachment.bin>
More information about the llvm-commits
mailing list