File tree 1 file changed +3
-4
lines changed
llvm/lib/Target/RISCV/GISel
1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change @@ -537,12 +537,11 @@ void RISCVInstructionSelector::getICMPOperandsForBranch(
537
537
RHS = MI.getOperand (3 ).getReg ();
538
538
539
539
// Adjust comparisons to use comparison with 0 if possible.
540
- int64_t Constant;
541
- if (mi_match (RHS, MRI, m_ICst (Constant))) {
540
+ if (auto Constant = getIConstantVRegSExtVal (RHS, MRI)) {
542
541
switch (ICMPCC) {
543
542
case CmpInst::Predicate::ICMP_SGT:
544
543
// Convert X > -1 to X >= 0
545
- if (Constant == -1 ) {
544
+ if (* Constant == -1 ) {
546
545
MachineInstr *Zero = MIB.buildConstant (MRI.getType (RHS), 0 );
547
546
selectConstant (*Zero, MIB, MRI);
548
547
CC = RISCVCC::COND_GE;
@@ -552,7 +551,7 @@ void RISCVInstructionSelector::getICMPOperandsForBranch(
552
551
break ;
553
552
case CmpInst::Predicate::ICMP_SLT:
554
553
// Convert X < 1 to 0 >= X
555
- if (Constant == 1 ) {
554
+ if (* Constant == 1 ) {
556
555
MachineInstr *Zero = MIB.buildConstant (MRI.getType (RHS), 0 );
557
556
selectConstant (*Zero, MIB, MRI);
558
557
CC = RISCVCC::COND_GE;
You can’t perform that action at this time.
0 commit comments