[llvm-dev] LLC does not do proper copy propagation (or copy coalescing)
Alex Susu via llvm-dev
llvm-dev at lists.llvm.org
Thu Jun 15 13:26:28 PDT 2017
Hello.
Could you please tell me how can I optimize with the back end (llc) the following
piece of assembly code generated by llc:
// NOTE: my processor accepts loops in the form of REPEAT(num_times)..END_REPEAT
R0 = ...
REPEAT(256)
R5 = R0; // basically unnecessary reg. copy
REPEAT(256)
R10 = LS[R4];
R2 = LS[R5];
R4 = R4 + R1;
R5 = R5 + R1; // should be R0 = R0 + R1
R10 = R2 * R10;
R3 = R3 + R10;
END_REPEAT;
REDUCE R3;
R0 = R5; // basically unnecessary reg. copy
END_REPEAT;
The above code has the deficiencies created basically by PHI elimination and not
applying a proper register copy propagation on machine instructions before Register
Allocation.
I see 3 options to address my problem:
- implement a case that handles this in PHI elimination (PHIElimination.cpp);
- create a new pass that does copy propagation (based on DFA) on machine
instructions before Register Allocation;
- optimize copy coalescing such as the standard one or the one activated by
-pbqp-coalescing in lib/CodeGen/RegAllocPBQP.cpp (there is an email also about PBQP
coalescing at http://lists.llvm.org/pipermail/llvm-dev/2016-June/100523.html).
Best regards,
Alex
More information about the llvm-dev
mailing list