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 @@ -734,6 +734,16 @@ EraVMCC::CondCodes EraVMInstrInfo::getCCCode(const MachineInstr &MI) const {
734734 return EraVMCC::COND_INVALID;
735735}
736736
737+ std::optional<DestSourcePair>
738+ EraVMInstrInfo::isCopyInstrImpl (const MachineInstr &MI) const {
739+ if (MI.getOpcode () == EraVM::ADDrrr_s &&
740+ MI.getOperand (2 ).getReg () == EraVM::R0 &&
741+ getCCCode (MI) == EraVMCC::COND_NONE) {
742+ return DestSourcePair{MI.getOperand (0 ), MI.getOperand (1 )};
743+ }
744+ return std::nullopt ;
745+ }
746+
737747// / Return whether outlining candidate ends with a tail call. This is true only
738748// / if it is a terminator that ends function, call to outlined function that
739749// / 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 () != CodeGenOptLevel::None)
323+ addPass (createMachineCopyPropagationPass (true ));
322324 addPass (createEraVMCombineAddressingModePass ());
323325 addPass (createEraVMExpandSelectPass ());
324326 addPass (createEraVMOptimizeSelectPostRAPass ());
Original file line number Diff line number Diff line change @@ -202,6 +202,7 @@ target triple = "eravm"
202202; CHECK-NEXT: Branch Probability Basic Block Placement
203203; CHECK-NEXT: Insert fentry calls
204204; CHECK-NEXT: Insert XRay ops
205+ ; CHECK-NEXT: Machine Copy Propagation Pass
205206; CHECK-NEXT: ReachingDefAnalysis
206207; CHECK-NEXT: MachineDominator Tree Construction
207208; 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