init_expr_once sets direct_load and direct_store arrays, which are indexed by
mode.  These are supposed to indicate "can we load a value of this mode from
memory" and similar for store.  It does this by passing a bunch of (set (reg)
(mem)) instructions to recog.

At the top of the function:

   /* Try indexing by frame ptr and try by stack ptr.
     It is known that on the Convex the stack ptr isn't a valid index.
     With luck, one or the other is valid on any machine.  */
  mem = gen_rtx_MEM (VOIDmode, stack_pointer_rtx);
  mem1 = gen_rtx_MEM (VOIDmode, frame_pointer_rtx);

That's actually base, not index, in current GCC parlance.  And the assumption
isn't true for Thumb.  You can load SImode using [sp], but not QImode.  And
frame_pointer_rtx is a pseudo that isn't valid to index off of anyway.  The
hard frame pointer is r7 for Thumb, and that would be a valid index.

Possibilities: also check hard_frame_pointer_rtx, also check a target-specified
register, find a valid register for each mode using ok_for_base_1.  The last
seems best except it would be the earliest call to REGNO_OK_FOR_BASE_P et
cetera in the compiler.  The ARM version will crash if reg_renumber isn't
allocated.

This isn't a big problem because we'll go on to handle QImode loads as bitfield
accesses and bitfield optimizations will more or less sort things out.  Fixing
it might enable some other RTL optimizations though.


-- 
           Summary: init_expr_once suboptimal for Thumb
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: drow at gcc dot gnu dot org
GCC target triplet: arm*-*


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35296

Reply via email to