diff options
author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2024-01-22 15:46:24 +0000 |
---|---|---|
committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2024-01-22 15:59:55 +0000 |
commit | 27eb8d53ae44e2f5a6259744446ea389afaf68a2 (patch) | |
tree | 868df5b37d85cfc09828e6cfdc57fe9762b0b804 | |
parent | e302950023cd99251371c5dc8a1e3b609dd5a8fe (diff) | |
download | llvm-27eb8d53ae44e2f5a6259744446ea389afaf68a2.zip llvm-27eb8d53ae44e2f5a6259744446ea389afaf68a2.tar.gz llvm-27eb8d53ae44e2f5a6259744446ea389afaf68a2.tar.bz2 |
[X86] printConstant - add ConstantVector handling
-rw-r--r-- | llvm/lib/Target/X86/X86MCInstLower.cpp | 28 | ||||
-rw-r--r-- | llvm/test/CodeGen/X86/widen_shuffle-1.ll | 2 |
2 files changed, 18 insertions, 12 deletions
diff --git a/llvm/lib/Target/X86/X86MCInstLower.cpp b/llvm/lib/Target/X86/X86MCInstLower.cpp index 5b26152..8bf099a 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 f55bc06..925b96f 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 ; |