[llvm] 27eb8d5 - [X86] printConstant - add ConstantVector handling
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 22 08:00:15 PST 2024
Author: Simon Pilgrim
Date: 2024-01-22T15:59:55Z
New Revision: 27eb8d53ae44e2f5a6259744446ea389afaf68a2
URL: https://github.com/llvm/llvm-project/commit/27eb8d53ae44e2f5a6259744446ea389afaf68a2
DIFF: https://github.com/llvm/llvm-project/commit/27eb8d53ae44e2f5a6259744446ea389afaf68a2.diff
LOG: [X86] printConstant - add ConstantVector handling
Added:
Modified:
llvm/lib/Target/X86/X86MCInstLower.cpp
llvm/test/CodeGen/X86/widen_shuffle-1.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86MCInstLower.cpp b/llvm/lib/Target/X86/X86MCInstLower.cpp
index 5b261522de3290..8bf099a1658169 100644
--- a/llvm/lib/Target/X86/X86MCInstLower.cpp
+++ b/llvm/lib/Target/X86/X86MCInstLower.cpp
@@ -1536,6 +1536,15 @@ static void printConstant(const Constant *COp, unsigned BitWidth,
else
CS << "?";
}
+ } else if (auto *CV = dyn_cast<ConstantVector>(COp)) {
+ unsigned EltBits = CV->getType()->getScalarSizeInBits();
+ unsigned E = std::min(BitWidth / EltBits, CV->getNumOperands());
+ assert((BitWidth % EltBits) == 0 && "Element size mismatch");
+ for (unsigned I = 0; I != E; ++I) {
+ if (I != 0)
+ CS << ",";
+ printConstant(CV->getOperand(I), EltBits, CS, PrintZero);
+ }
} else {
CS << "?";
}
@@ -1550,18 +1559,15 @@ static void printZeroUpperMove(const MachineInstr *MI, MCStreamer &OutStreamer,
CS << X86ATTInstPrinter::getRegisterName(DstOp.getReg()) << " = ";
if (auto *C = X86::getConstantFromPool(*MI, 1)) {
- if (isa<ConstantInt>(C) || isa<ConstantFP>(C) ||
- isa<ConstantDataSequential>(C)) {
- CS << "[";
- printConstant(C, SclWidth, CS);
- for (int I = 1, E = VecWidth / SclWidth; I < E; ++I) {
- CS << ",";
- printConstant(C, SclWidth, CS, true);
- }
- CS << "]";
- OutStreamer.AddComment(CS.str());
- return; // early-out
+ CS << "[";
+ printConstant(C, SclWidth, CS);
+ for (int I = 1, E = VecWidth / SclWidth; I < E; ++I) {
+ CS << ",";
+ printConstant(C, SclWidth, CS, true);
}
+ CS << "]";
+ OutStreamer.AddComment(CS.str());
+ return; // early-out
}
// We didn't find a constant load, fallback to a shuffle mask decode.
diff --git a/llvm/test/CodeGen/X86/widen_shuffle-1.ll b/llvm/test/CodeGen/X86/widen_shuffle-1.ll
index f55bc06bc3c45f..925b96f5e346cd 100644
--- a/llvm/test/CodeGen/X86/widen_shuffle-1.ll
+++ b/llvm/test/CodeGen/X86/widen_shuffle-1.ll
@@ -105,7 +105,7 @@ define void @shuf5(ptr %p) nounwind {
; X86-LABEL: shuf5:
; X86: # %bb.0:
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
-; X86-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
+; X86-NEXT: movsd {{.*#+}} xmm0 = [33,33,33,33,33,33,33,33,0,0,0,0,0,0,0,0]
; X86-NEXT: movsd %xmm0, (%eax)
; X86-NEXT: retl
;
More information about the llvm-commits
mailing list