------- Comment #10 from rsandifo at gcc dot gnu dot org 2007-09-04 09:54 ------- Created an attachment (id=14155) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=14155&action=view) Proposed patch
David, thanks for the analysis and reduced testcase. Re comment #7: I agree that we can't drop the offset_within_block_p check entirely. However (re comment #9) adjust_address_1 is actually making a legitimate optimisation here. It is given a memory that is known to be 8-byte-aligned, so it knows that adding 4 to the LO_SUM will not induce a carry. The problem is that the mips_classify_address has no access to that information; all it sees is the narrowed MEM. This PR is related to: http://thread.gmane.org/gmane.comp.gcc.patches/139565/focus=140004 I still think the final fix in that thread: http://gcc.gnu.org/viewcvs/trunk/gcc/config/mips/mips.c?r1=124833&r2=124832&pathrev=124833 was the right one for that bug because we always have access to a TLS's decl, so we can apply suitably small offsets to HIGHs as well as LO_SUMs. However, although we do have access to decl in the testcase for this PR, we won't for all (non-TLS) %hi/%los, so a similar fix won't work here. I think we have to trust the creator of the LO_SUM to do something vaguely sane. Target-independent code that creates a LO_SUM should also create and verify the associated HIGH, which must use the same symbol as the LO_SUM. Target-independent code that adds an offset to a LO_SUM should prove that the offset will not induce a carry. Failure to do either of these things would be a bug. And the MIPS backend should only create LO_SUMs for valid symbolic constants, with the high part being either a HIGH or a copy of _gp. So I'm wondering about the attached patch. Note that the lo_sum mips.md patterns are already OK, because they use immediate_operand. Richard -- rsandifo at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|unassigned at gcc dot gnu |rsandifo at gcc dot gnu dot |dot org |org Status|NEW |ASSIGNED http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33256