Skip to content

Commit b8bbd5f

Browse files
committed
[X86] X86InstrFoldTables.cpp - add Op4 Broadcast Fold/Unfold table entries
Prep work for #73509 (missed in #73654)
1 parent ba52310 commit b8bbd5f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

llvm/lib/Target/X86/X86InstrFoldTables.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ using namespace llvm;
2323
// are currently emitted in X86GenInstrInfo.inc in alphabetical order. Which
2424
// makes sorting these tables a simple matter of alphabetizing the table.
2525
#include "X86GenFoldTables.inc"
26+
2627
// Table to map instructions safe to broadcast using a different width from the
2728
// element width.
2829
static const X86FoldTableEntry BroadcastSizeTable2[] = {
@@ -186,6 +187,10 @@ struct X86MemUnfoldTable {
186187
// Index 3, folded broadcast
187188
addTableEntry(Entry, TB_INDEX_3 | TB_FOLDED_LOAD | TB_FOLDED_BCAST);
188189

190+
for (const X86FoldTableEntry &Entry : BroadcastTable4)
191+
// Index 4, folded broadcast
192+
addTableEntry(Entry, TB_INDEX_4 | TB_FOLDED_LOAD | TB_FOLDED_BCAST);
193+
189194
// Sort the memory->reg unfold table.
190195
array_pod_sort(Table.begin(), Table.end());
191196

@@ -266,6 +271,17 @@ struct X86BroadcastFoldTable {
266271
}
267272
}
268273

274+
for (const X86FoldTableEntry &Reg2Bcst : BroadcastTable4) {
275+
unsigned RegOp = Reg2Bcst.KeyOp;
276+
unsigned BcstOp = Reg2Bcst.DstOp;
277+
if (const X86FoldTableEntry *Reg2Mem = lookupFoldTable(RegOp, 4)) {
278+
unsigned MemOp = Reg2Mem->DstOp;
279+
uint16_t Flags = Reg2Mem->Flags | Reg2Bcst.Flags | TB_INDEX_4 |
280+
TB_FOLDED_LOAD | TB_FOLDED_BCAST;
281+
Table.push_back({MemOp, BcstOp, Flags});
282+
}
283+
}
284+
269285
// Sort the memory->broadcast fold table.
270286
array_pod_sort(Table.begin(), Table.end());
271287
}

0 commit comments

Comments
 (0)