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 {
732732 return EraVMCC::COND_INVALID;
733733}
734734
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+
735745// / Return whether outlining candidate ends with a tail call. This is true only
736746// / if it is a terminator that ends function, call to outlined function that
737747// / 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 {
406406 // return true if the update is successful
407407 bool updateCCCode (MachineInstr &MI, EraVMCC::CondCodes CC) const ;
408408
409+ std::optional<DestSourcePair>
410+ isCopyInstrImpl (const MachineInstr &MI) const override ;
411+
409412 unsigned defaultOutlineReruns () const override { return 5 ; }
410413
411414 bool shouldOutlineFromFunctionByDefault (MachineFunction &MF) const override ;
Original file line number Diff line number Diff line change @@ -319,6 +319,8 @@ void EraVMPassConfig::addPreSched2() {
319319}
320320
321321void EraVMPassConfig::addPreEmitPass () {
322+ if (getOptLevel () != CodeGenOpt::None)
323+ addPass (createMachineCopyPropagationPass (true ));
322324 addPass (createEraVMCombineAddressingModePass ());
323325 addPass (createEraVMExpandSelectPass ());
324326 addPass (createEraVMOptimizeSelectPostRAPass ());
Original file line number Diff line number Diff line change @@ -200,6 +200,7 @@ target triple = "eravm"
200200; CHECK-NEXT: Branch Probability Basic Block Placement
201201; CHECK-NEXT: Insert fentry calls
202202; CHECK-NEXT: Insert XRay ops
203+ ; CHECK-NEXT: Machine Copy Propagation Pass
203204; CHECK-NEXT: ReachingDefAnalysis
204205; CHECK-NEXT: MachineDominator Tree Construction
205206; 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"
77define i256 @test (i256 %dummy , ptr addrspace (3 ) %0 ) {
88; CHECK-LABEL: test:
99; CHECK: ; %bb.0:
10- ; CHECK-NEXT: add r2, r0, r1
11- ; CHECK-NEXT: and 255, r1, r1
10+ ; CHECK-NEXT: and 255, r2, r1
1211; CHECK-NEXT: ret
1312 %ptrtoint = ptrtoint ptr addrspace (3 ) %0 to i256
1413 %and = and i256 %ptrtoint , 255
You can’t perform that action at this time.
0 commit comments