This is the mail archive of the gcc@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]

combiner and paradoxical subreg question....


I'm working on a new target port currently based on 3.0.4. I'm looking
into a problem in which a sign extension is inappropriately optimised
away.I suspect the problem originates in the combiner, can anyone shed
some light on whats going on here??? This is what I have so far:

The combiner eventually gets around to expanding {sign,zero}_extends in:

combine.c:expand_compound_operation ()

In this scenario it performs the following rewrite:

(sign_extend:SI (mem:QI (reg/f:SI 168) 0)) => (subreg:SI (mem:QI
(reg/f:SI 168) 0) 0)

The relevant code fragment is something like:

combine.c:9662ish:gen_lowpart_for_combine ()

      /* If we want to refer to something bigger than the original
memref,
      generate a perverse subreg instead.  That will force a reload
      of the original memref X.  */
      if (GET_MODE_SIZE (GET_MODE (x)) < GET_MODE_SIZE (mode))
     return gen_rtx_SUBREG (mode, x, 0);

I'm slightly confused by this, my understanding of paradoxical subreg's
is that they are used to refer to something in  a wider mode where we
don;t care about the value of the additional bits. Are there situations
where a paradoxical subreg implies zero or sign extension rather than
undefined???

Subsequently when we get around to 'splitting' the above fragment, back
in:
combine.c:2277ish:do_try_combine ()

#ifdef INSN_SCHEDULING
   /* If *SPLIT is a paradoxical SUBREG, when we split it, it should
      be written as a ZERO_EXTEND.  */
   if (split_code == SUBREG && GET_CODE (SUBREG_REG (*split)) == MEM)
     SUBST (*split, gen_rtx_combine (ZERO_EXTEND, split_mode,
         XEXP (*split, 0)));
#endif

This performs the rewrite:
(subreg:SI (mem:QI (reg/f:SI 168) 0) 0) => (zero_extend:SI (mem:QI
(reg/f:SI 168) 0))

This code fragment switches the paradoxical subreg for a zero_extend, so
the combiner has now managed the overall rewrite:

(sign_extend:SI (mem:QI (reg/f:SI 168) 0))
=>
(subreg:SI (mem:QI (reg/f:SI 168) 0) 0)
=>
(zero_extend:SI (mem:QI (reg/f:SI 168) 0))

So can someone explain:
* What does a paradoxial subreg really represent.
* Is it ever safe to rewrite a sign_extend to a paradoxical subreg.

Thanks
/Marcus

--
----------------------------------------------------------------------
ms@siroyan.com,                                Marcus Shawcroft
200 Brook Drive, Green Park,                   Siroyan Limited
Reading, RG2 6UB, United Kingdom               0118 925 6374/Fx949 7228





**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


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