@@ -1411,11 +1411,6 @@ void EraVMTargetLowering::AdjustInstrPostInstrSelection(MachineInstr &MI,
1411
1411
SDNode *Node) const {
1412
1412
assert (MI.hasPostISelHook () && " Expected instruction to have post-isel hook" );
1413
1413
1414
- // Set NoMerge to gasleft instructions. This has to be in sync with nomerge
1415
- // attribute in IntrinsicsEraVM.td for this intrinsic.
1416
- if (MI.getOpcode () == EraVM::CTXGasLeft)
1417
- MI.setFlag (MachineInstr::MIFlag::NoMerge);
1418
-
1419
1414
// The overflow LT aka COND_OF caused by uaddo and umulo hasn't reversal
1420
1415
// version actually, the GE can't be used according to the spec. We need to
1421
1416
// add early-clobber attribute to the output register to prevent the RegAlloc
@@ -1425,12 +1420,35 @@ void EraVMTargetLowering::AdjustInstrPostInstrSelection(MachineInstr &MI,
1425
1420
// out = SELrrr i1 %ov, in0, in1, COND_OF
1426
1421
//
1427
1422
// when out and in0 are assigned to same register.
1428
- if (EraVM::isSelect (MI) &&
1429
- getImmOrCImm (*EraVM::ccIterator (MI)) == EraVMCC::COND_OF) {
1423
+ if (EraVM::isSelect (MI)) {
1424
+ if (getImmOrCImm (*EraVM::ccIterator (MI)) != EraVMCC::COND_OF)
1425
+ return ;
1430
1426
assert (
1431
1427
(EraVM::argumentType (EraVM::ArgumentKind::In0, MI.getOpcode ()) ==
1432
1428
EraVM::ArgumentType::Register) &&
1433
1429
" Expect register operand for the 1st input of SELECT with overflow LT" );
1434
1430
EraVM::out0Iterator (MI)->setIsEarlyClobber ();
1431
+ return ;
1432
+ }
1433
+
1434
+ switch (MI.getOpcode ()) {
1435
+ default :
1436
+ llvm_unreachable (" Unexpected instruction passed to post-isel hook" );
1437
+ case EraVM::JCl: {
1438
+ const auto *CCOperand = EraVM::ccIterator (MI);
1439
+ if (getImmOrCImm (*CCOperand) == EraVMCC::COND_NONE) {
1440
+ // Instruction is not predicated - drop implicit use of Flags register.
1441
+ int FlagsUseIdx = MI.findRegisterUseOperandIdx (EraVM::Flags);
1442
+ assert (FlagsUseIdx < 0 && " Conservative Uses=[Flags] expected" );
1443
+ assert (MI.getOperand (FlagsUseIdx).isImplicit ());
1444
+ MI.removeOperand (FlagsUseIdx);
1445
+ }
1446
+ break ;
1447
+ }
1448
+ case EraVM::CTXGasLeft:
1449
+ // Set NoMerge to gasleft instructions. This has to be in sync with nomerge
1450
+ // attribute in IntrinsicsEraVM.td for this intrinsic.
1451
+ MI.setFlag (MachineInstr::MIFlag::NoMerge);
1452
+ break ;
1435
1453
}
1436
1454
}
0 commit comments