This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Wrap calculation of PIC address into a single instruction


On 6/24/10 1:50 AM, Maxim Kuvyrkov wrote:
On 6/24/10 1:22 AM, Steven Bosscher wrote:
On Wed, Jun 23, 2010 at 11:19 PM, Maxim
Kuvyrkov<maxim@codesourcery.com> wrote:
This patch enables optimizations, particularly GCSE, handle
calculation of
PIC addresses. GCSE tracks only single instructions, so it can't handle
two-instruction calculation of PIC address.

With this patch, calculations of PIC addresses are represented as single
instructions allowing GCSE eliminate all but the first address
calculation
for global variables.

Any comments?

Yes. This is what we added GCSE's ability to eliminate redundancies from REG_EQUAL notes for. If your PIC addresses have a REG_EQUAL note, GCSE is (or should be) already able to eliminate redundant address calculations.

You know, it turns out GCSE can eliminate calculation of PIC addresses on ARM. When I started working on improving code hoisting the example with PIC address wasn't fully optimized without this patch.

It was late in the night when I checked the generated code and, although GCSE of PIC addresses for ARM is now better, it is still not as good as with this patch.


GCSE cannot use (REG_EQUAL (symbol_ref)) note on the second instruction because can_assign_to_reg_without_clobbers returns false for symbol_ref when compiling PIC code. (Symbol_ref) is not a LEGITIMATE_PIC_OPERAND_P, so it not a general_operand either. The second check in can_assign_to_reg_without_clobbers returns false as (set (reg) (symbol_ref)) yields invalid instruction.

AFAICT, GCSE cannot optimize a bare symbol_ref for ARM PIC code because it has no guarantee that emit_move_insn (reg, symbol_ref) will generate simple enough code.


Now, apparently, one of the other GCSE improvements (VBEout computation, probably) fixed the underlying problem.

Improvements to GCSE'ing constants were able to optimize half of second and subsequent address calculations.



Richard, unless you think the patch may be valuable for some other reason, I'm dropping it.

The patch stands for now.


Thank you,

--
Maxim Kuvyrkov
CodeSourcery
maxim@codesourcery.com
(650) 331-3385 x724


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]