File tree Expand file tree Collapse file tree 5 files changed +17
-2
lines changed Expand file tree Collapse file tree 5 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -732,6 +732,16 @@ EraVMCC::CondCodes EraVMInstrInfo::getCCCode(const MachineInstr &MI) const {
732
732
return EraVMCC::COND_INVALID;
733
733
}
734
734
735
+ std::optional<DestSourcePair>
736
+ EraVMInstrInfo::isCopyInstrImpl (const MachineInstr &MI) const {
737
+ if (MI.getOpcode () == EraVM::ADDrrr_s &&
738
+ MI.getOperand (2 ).getReg () == EraVM::R0 &&
739
+ getCCCode (MI) == EraVMCC::COND_NONE) {
740
+ return DestSourcePair{MI.getOperand (0 ), MI.getOperand (1 )};
741
+ }
742
+ return std::nullopt;
743
+ }
744
+
735
745
// / Return whether outlining candidate ends with a tail call. This is true only
736
746
// / if it is a terminator that ends function, call to outlined function that
737
747
// / ends with a tail call, or call to a no return function.
Original file line number Diff line number Diff line change @@ -406,6 +406,9 @@ class EraVMInstrInfo : public EraVMGenInstrInfo {
406
406
// return true if the update is successful
407
407
bool updateCCCode (MachineInstr &MI, EraVMCC::CondCodes CC) const ;
408
408
409
+ std::optional<DestSourcePair>
410
+ isCopyInstrImpl (const MachineInstr &MI) const override ;
411
+
409
412
unsigned defaultOutlineReruns () const override { return 5 ; }
410
413
411
414
bool shouldOutlineFromFunctionByDefault (MachineFunction &MF) const override ;
Original file line number Diff line number Diff line change @@ -319,6 +319,8 @@ void EraVMPassConfig::addPreSched2() {
319
319
}
320
320
321
321
void EraVMPassConfig::addPreEmitPass () {
322
+ if (getOptLevel () != CodeGenOpt::None)
323
+ addPass (createMachineCopyPropagationPass (true ));
322
324
addPass (createEraVMCombineAddressingModePass ());
323
325
addPass (createEraVMExpandSelectPass ());
324
326
addPass (createEraVMOptimizeSelectPostRAPass ());
Original file line number Diff line number Diff line change @@ -200,6 +200,7 @@ target triple = "eravm"
200
200
; CHECK-NEXT: Branch Probability Basic Block Placement
201
201
; CHECK-NEXT: Insert fentry calls
202
202
; CHECK-NEXT: Insert XRay ops
203
+ ; CHECK-NEXT: Machine Copy Propagation Pass
203
204
; CHECK-NEXT: ReachingDefAnalysis
204
205
; CHECK-NEXT: MachineDominator Tree Construction
205
206
; CHECK-NEXT: EraVM combine instuctions to use complex addressing modes
Original file line number Diff line number Diff line change @@ -7,8 +7,7 @@ target triple = "eravm"
7
7
define i256 @test (i256 %dummy , ptr addrspace (3 ) %0 ) {
8
8
; CHECK-LABEL: test:
9
9
; CHECK: ; %bb.0:
10
- ; CHECK-NEXT: add r2, r0, r1
11
- ; CHECK-NEXT: and 255, r1, r1
10
+ ; CHECK-NEXT: and 255, r2, r1
12
11
; CHECK-NEXT: ret
13
12
%ptrtoint = ptrtoint ptr addrspace (3 ) %0 to i256
14
13
%and = and i256 %ptrtoint , 255
You can’t perform that action at this time.
0 commit comments