Skip to content

Commit bc6370a

Browse files
committed
[X86] addConstantComments - split VPERMILPS/VPERMILPD handling to reduce repeated switch cases etc. NFC.
1 parent 6639743 commit bc6370a

File tree

1 file changed

+12
-33
lines changed

1 file changed

+12
-33
lines changed

llvm/lib/Target/X86/X86MCInstLower.cpp

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,7 +1782,17 @@ static void addConstantComments(const MachineInstr *MI,
17821782
case X86::VPERMILPSZ256rmkz:
17831783
case X86::VPERMILPSZrm:
17841784
case X86::VPERMILPSZrmk:
1785-
case X86::VPERMILPSZrmkz:
1785+
case X86::VPERMILPSZrmkz: {
1786+
unsigned SrcIdx = getSrcIdx(MI, 1);
1787+
if (auto *C = X86::getConstantFromPool(*MI, SrcIdx + 1)) {
1788+
unsigned Width = getRegisterWidth(MI->getDesc().operands()[0]);
1789+
SmallVector<int, 16> Mask;
1790+
DecodeVPERMILPMask(C, 32, Width, Mask);
1791+
if (!Mask.empty())
1792+
OutStreamer.AddComment(getShuffleComment(MI, SrcIdx, SrcIdx, Mask));
1793+
}
1794+
break;
1795+
}
17861796
case X86::VPERMILPDrm:
17871797
case X86::VPERMILPDYrm:
17881798
case X86::VPERMILPDZ128rm:
@@ -1794,42 +1804,11 @@ static void addConstantComments(const MachineInstr *MI,
17941804
case X86::VPERMILPDZrm:
17951805
case X86::VPERMILPDZrmk:
17961806
case X86::VPERMILPDZrmkz: {
1797-
unsigned ElSize;
1798-
switch (MI->getOpcode()) {
1799-
default: llvm_unreachable("Invalid opcode");
1800-
case X86::VPERMILPSrm:
1801-
case X86::VPERMILPSYrm:
1802-
case X86::VPERMILPSZ128rm:
1803-
case X86::VPERMILPSZ256rm:
1804-
case X86::VPERMILPSZrm:
1805-
case X86::VPERMILPSZ128rmkz:
1806-
case X86::VPERMILPSZ256rmkz:
1807-
case X86::VPERMILPSZrmkz:
1808-
case X86::VPERMILPSZ128rmk:
1809-
case X86::VPERMILPSZ256rmk:
1810-
case X86::VPERMILPSZrmk:
1811-
ElSize = 32;
1812-
break;
1813-
case X86::VPERMILPDrm:
1814-
case X86::VPERMILPDYrm:
1815-
case X86::VPERMILPDZ128rm:
1816-
case X86::VPERMILPDZ256rm:
1817-
case X86::VPERMILPDZrm:
1818-
case X86::VPERMILPDZ128rmkz:
1819-
case X86::VPERMILPDZ256rmkz:
1820-
case X86::VPERMILPDZrmkz:
1821-
case X86::VPERMILPDZ128rmk:
1822-
case X86::VPERMILPDZ256rmk:
1823-
case X86::VPERMILPDZrmk:
1824-
ElSize = 64;
1825-
break;
1826-
}
1827-
18281807
unsigned SrcIdx = getSrcIdx(MI, 1);
18291808
if (auto *C = X86::getConstantFromPool(*MI, SrcIdx + 1)) {
18301809
unsigned Width = getRegisterWidth(MI->getDesc().operands()[0]);
18311810
SmallVector<int, 16> Mask;
1832-
DecodeVPERMILPMask(C, ElSize, Width, Mask);
1811+
DecodeVPERMILPMask(C, 64, Width, Mask);
18331812
if (!Mask.empty())
18341813
OutStreamer.AddComment(getShuffleComment(MI, SrcIdx, SrcIdx, Mask));
18351814
}

0 commit comments

Comments
 (0)