Skip to content

Commit 236b315

Browse files
authored
[RISCV] Remove extra operands from Zcb compression patterns. NFC (#150541)
Tied operands in the destination are not supposed to be listed. This didn't cause a functional issue because none of the code noticed that extra operand was even there. Simplify verifyDagOpCount to catch this case.
1 parent 9cd2413 commit 236b315

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfoZc.td

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -291,31 +291,31 @@ def : CompressPat<(MUL GPRC:$rs1, GPRC:$rs2, GPRC:$rs1),
291291

292292
let Predicates = [HasStdExtZcb, HasStdExtZbb] in{
293293
def : CompressPat<(SEXT_B GPRC:$rs1, GPRC:$rs1),
294-
(C_SEXT_B GPRC:$rs1, GPRC:$rs1)>;
294+
(C_SEXT_B GPRC:$rs1)>;
295295
def : CompressPat<(SEXT_H GPRC:$rs1, GPRC:$rs1),
296-
(C_SEXT_H GPRC:$rs1, GPRC:$rs1)>;
296+
(C_SEXT_H GPRC:$rs1)>;
297297
} // Predicates = [HasStdExtZcb, HasStdExtZbb]
298298

299299
let Predicates = [HasStdExtZcb, HasStdExtZbb] in{
300300
def : CompressPat<(ZEXT_H_RV32 GPRC:$rs1, GPRC:$rs1),
301-
(C_ZEXT_H GPRC:$rs1, GPRC:$rs1)>;
301+
(C_ZEXT_H GPRC:$rs1)>;
302302
def : CompressPat<(ZEXT_H_RV64 GPRC:$rs1, GPRC:$rs1),
303-
(C_ZEXT_H GPRC:$rs1, GPRC:$rs1)>;
303+
(C_ZEXT_H GPRC:$rs1)>;
304304
} // Predicates = [HasStdExtZcb, HasStdExtZbb]
305305

306306
let Predicates = [HasStdExtZcb] in{
307307
def : CompressPat<(ANDI GPRC:$rs1, GPRC:$rs1, 255),
308-
(C_ZEXT_B GPRC:$rs1, GPRC:$rs1)>;
308+
(C_ZEXT_B GPRC:$rs1)>;
309309
} // Predicates = [HasStdExtZcb]
310310

311311
let Predicates = [HasStdExtZcb, HasStdExtZba, IsRV64] in{
312312
def : CompressPat<(ADD_UW GPRC:$rs1, GPRC:$rs1, X0),
313-
(C_ZEXT_W GPRC:$rs1, GPRC:$rs1)>;
313+
(C_ZEXT_W GPRC:$rs1)>;
314314
} // Predicates = [HasStdExtZcb, HasStdExtZba, IsRV64]
315315

316316
let Predicates = [HasStdExtZcb] in{
317317
def : CompressPat<(XORI GPRC:$rs1, GPRC:$rs1, -1),
318-
(C_NOT GPRC:$rs1, GPRC:$rs1)>;
318+
(C_NOT GPRC:$rs1)>;
319319
}
320320

321321
let Predicates = [HasStdExtZcb] in{

llvm/utils/TableGen/CompressInstEmitter.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -326,22 +326,13 @@ static bool verifyDagOpCount(const CodeGenInstruction &Inst, const DagInit *Dag,
326326
TiedOpCount++;
327327
}
328328

329-
if (Dag->getNumArgs() == NumMIOperands)
330-
return true;
331-
332329
// Source instructions are non compressed instructions and have at most one
333330
// tied operand.
334331
if (IsSource && (TiedOpCount > 1))
335332
PrintFatalError(Inst.TheDef->getLoc(),
336333
"Input operands for Inst '" + Inst.TheDef->getName() +
337334
"' and input Dag operand count mismatch");
338335

339-
// The Dag can't have more arguments than the Instruction.
340-
if (Dag->getNumArgs() > NumMIOperands)
341-
PrintFatalError(Inst.TheDef->getLoc(),
342-
"Inst '" + Inst.TheDef->getName() +
343-
"' and Dag operand count mismatch");
344-
345336
// The Instruction might have tied operands so the Dag might have
346337
// a fewer operand count.
347338
if (Dag->getNumArgs() != (NumMIOperands - TiedOpCount))

0 commit comments

Comments
 (0)