Skip to content

Commit 27eb8d5

Browse files
committed
[X86] printConstant - add ConstantVector handling
1 parent e302950 commit 27eb8d5

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

llvm/lib/Target/X86/X86MCInstLower.cpp

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,6 +1536,15 @@ static void printConstant(const Constant *COp, unsigned BitWidth,
15361536
else
15371537
CS << "?";
15381538
}
1539+
} else if (auto *CV = dyn_cast<ConstantVector>(COp)) {
1540+
unsigned EltBits = CV->getType()->getScalarSizeInBits();
1541+
unsigned E = std::min(BitWidth / EltBits, CV->getNumOperands());
1542+
assert((BitWidth % EltBits) == 0 && "Element size mismatch");
1543+
for (unsigned I = 0; I != E; ++I) {
1544+
if (I != 0)
1545+
CS << ",";
1546+
printConstant(CV->getOperand(I), EltBits, CS, PrintZero);
1547+
}
15391548
} else {
15401549
CS << "?";
15411550
}
@@ -1550,18 +1559,15 @@ static void printZeroUpperMove(const MachineInstr *MI, MCStreamer &OutStreamer,
15501559
CS << X86ATTInstPrinter::getRegisterName(DstOp.getReg()) << " = ";
15511560

15521561
if (auto *C = X86::getConstantFromPool(*MI, 1)) {
1553-
if (isa<ConstantInt>(C) || isa<ConstantFP>(C) ||
1554-
isa<ConstantDataSequential>(C)) {
1555-
CS << "[";
1556-
printConstant(C, SclWidth, CS);
1557-
for (int I = 1, E = VecWidth / SclWidth; I < E; ++I) {
1558-
CS << ",";
1559-
printConstant(C, SclWidth, CS, true);
1560-
}
1561-
CS << "]";
1562-
OutStreamer.AddComment(CS.str());
1563-
return; // early-out
1562+
CS << "[";
1563+
printConstant(C, SclWidth, CS);
1564+
for (int I = 1, E = VecWidth / SclWidth; I < E; ++I) {
1565+
CS << ",";
1566+
printConstant(C, SclWidth, CS, true);
15641567
}
1568+
CS << "]";
1569+
OutStreamer.AddComment(CS.str());
1570+
return; // early-out
15651571
}
15661572

15671573
// We didn't find a constant load, fallback to a shuffle mask decode.

llvm/test/CodeGen/X86/widen_shuffle-1.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ define void @shuf5(ptr %p) nounwind {
105105
; X86-LABEL: shuf5:
106106
; X86: # %bb.0:
107107
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
108-
; X86-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
108+
; X86-NEXT: movsd {{.*#+}} xmm0 = [33,33,33,33,33,33,33,33,0,0,0,0,0,0,0,0]
109109
; X86-NEXT: movsd %xmm0, (%eax)
110110
; X86-NEXT: retl
111111
;

0 commit comments

Comments
 (0)