[llvm] 6639743 - [X86] Add common getSrcIdx helper to determine source index after AVX512 masked predicates. NFC.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 5 05:48:33 PST 2024
Author: Simon Pilgrim
Date: 2024-02-05T13:48:15Z
New Revision: 66397435ed83c2247f49d302246ba5a87f4dd85f
URL: https://github.com/llvm/llvm-project/commit/66397435ed83c2247f49d302246ba5a87f4dd85f
DIFF: https://github.com/llvm/llvm-project/commit/66397435ed83c2247f49d302246ba5a87f4dd85f.diff
LOG: [X86] Add common getSrcIdx helper to determine source index after AVX512 masked predicates. NFC.
Added:
Modified:
llvm/lib/Target/X86/X86MCInstLower.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86MCInstLower.cpp b/llvm/lib/Target/X86/X86MCInstLower.cpp
index 45dd98cde6fa1..d1f835b20a72d 100644
--- a/llvm/lib/Target/X86/X86MCInstLower.cpp
+++ b/llvm/lib/Target/X86/X86MCInstLower.cpp
@@ -1400,6 +1400,18 @@ static unsigned getRegisterWidth(const MCOperandInfo &Info) {
llvm_unreachable("Unknown register class!");
}
+static unsigned getSrcIdx(const MachineInstr* MI, unsigned SrcIdx) {
+ if (X86II::isKMasked(MI->getDesc().TSFlags)) {
+ // Skip mask operand.
+ ++SrcIdx;
+ if (X86II::isKMergeMasked(MI->getDesc().TSFlags)) {
+ // Skip passthru operand.
+ ++SrcIdx;
+ }
+ }
+ return SrcIdx;
+}
+
static std::string getShuffleComment(const MachineInstr *MI, unsigned SrcOp1Idx,
unsigned SrcOp2Idx, ArrayRef<int> Mask) {
std::string Comment;
@@ -1749,16 +1761,7 @@ static void addConstantComments(const MachineInstr *MI,
case X86::VPSHUFBZrm:
case X86::VPSHUFBZrmk:
case X86::VPSHUFBZrmkz: {
- unsigned SrcIdx = 1;
- if (X86II::isKMasked(MI->getDesc().TSFlags)) {
- // Skip mask operand.
- ++SrcIdx;
- if (X86II::isKMergeMasked(MI->getDesc().TSFlags)) {
- // Skip passthru operand.
- ++SrcIdx;
- }
- }
-
+ unsigned SrcIdx = getSrcIdx(MI, 1);
if (auto *C = X86::getConstantFromPool(*MI, SrcIdx + 1)) {
unsigned Width = getRegisterWidth(MI->getDesc().operands()[0]);
SmallVector<int, 64> Mask;
@@ -1822,16 +1825,7 @@ static void addConstantComments(const MachineInstr *MI,
break;
}
- unsigned SrcIdx = 1;
- if (X86II::isKMasked(MI->getDesc().TSFlags)) {
- // Skip mask operand.
- ++SrcIdx;
- if (X86II::isKMergeMasked(MI->getDesc().TSFlags)) {
- // Skip passthru operand.
- ++SrcIdx;
- }
- }
-
+ unsigned SrcIdx = getSrcIdx(MI, 1);
if (auto *C = X86::getConstantFromPool(*MI, SrcIdx + 1)) {
unsigned Width = getRegisterWidth(MI->getDesc().operands()[0]);
SmallVector<int, 16> Mask;
More information about the llvm-commits
mailing list