Skip to content

Commit 0e1d1d7

Browse files
Use mICst
1 parent 99a5521 commit 0e1d1d7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

llvm/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -537,11 +537,12 @@ void RISCVInstructionSelector::getICMPOperandsForBranch(
537537
RHS = MI.getOperand(3).getReg();
538538

539539
// Adjust comparisons to use comparison with 0 if possible.
540-
if (auto Constant = matchConstant<int64_t>(RHS, MRI)) {
540+
int64_t Constant;
541+
if (mi_match(RHS, MRI, m_ICst(Constant))) {
541542
switch (ICMPCC) {
542543
case CmpInst::Predicate::ICMP_SGT:
543544
// Convert X > -1 to X >= 0
544-
if (*Constant == -1) {
545+
if (Constant == -1) {
545546
MachineInstr *Zero = MIB.buildConstant(MRI.getType(RHS), 0);
546547
selectConstant(*Zero, MIB, MRI);
547548
CC = RISCVCC::COND_GE;
@@ -551,7 +552,7 @@ void RISCVInstructionSelector::getICMPOperandsForBranch(
551552
break;
552553
case CmpInst::Predicate::ICMP_SLT:
553554
// Convert X < 1 to 0 >= X
554-
if (*Constant == 1) {
555+
if (Constant == 1) {
555556
MachineInstr *Zero = MIB.buildConstant(MRI.getType(RHS), 0);
556557
selectConstant(*Zero, MIB, MRI);
557558
CC = RISCVCC::COND_GE;

0 commit comments

Comments
 (0)