public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* A potential bug in lra-constraints.c for special_memory_constraint?
@ 2017-07-10 13:59 Qing Zhao
  2017-07-11  7:47 ` Eric Botcazou
  0 siblings, 1 reply; 12+ messages in thread
From: Qing Zhao @ 2017-07-10 13:59 UTC (permalink / raw)
  To: gcc-patches; +Cc: qing Zhao

Hi,team:


The following doc for memory_constraint and special_memory_constraint seems
imply that the handling of the special_memory_constraint in lra-constraints.c
is NOT correct:

(https://gcc.gnu.org/onlinedocs/gccint/Define-Constraints.html#Define-Constraints)

MD Expression: define_memory_constraint name docstring exp

    Use this expression for constraints that match a subset of all memory
operands: that is, reload can make them match by converting the operand to
the form `(mem (reg X))¿, where X is a base register (from the register class
specified by BASE_REG_CLASS, see Register Classes).

….

    The syntax and semantics are otherwise identical to define_constraint.


MD Expression: define_special_memory_constraint name docstring exp

    Use this expression for constraints that match a subset of all memory
operands: that is, reload can not make them match by reloading the address as
it is described for define_memory_constraint or such address reload is
undesirable with the performance point of view.

    For example, define_special_memory_constraint can be useful if
specifically aligned memory is necessary or desirable for some insn operand.

    The syntax and semantics are otherwise identical to define_constraint.


From the above doc, the major difference between a memory_constraint and a
special_memory_constraint is:  whether "reload can or cannot make them match
by reloading the address".

For memory_constraint,  the reload is Okay, however, for
special_memory_constraint, the reload is NOT Okay.

I am not sure whether the RELOAD includes Spill or not, if it is, then the
current handling of special_memory_constraint is NOT correct:
(lra-constraints.c)

2088                     case CT_SPECIAL_MEMORY:
2089                       if (MEM_P (op)
2090                           && satisfies_memory_constraint_p (op, cn))
2091                         win = true;
2092                       else if (spilled_pseudo_p (op))
2093                         win = true;
2094                       break;

line 2092-2093 permits the memory spill, which seems need to be avoided for
SPECIAL_MEMORY_Constraint.

the thing I need to confirm is:

whether “spill” is considered as RELOAD or NOT?

if the spill IS RELOAD, then the handling of special_memory_constraint in lra-constraints.c is 
definitely wrong, we should fix this issue in upstream. 

thanks.

Qing

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2017-07-12 15:40 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-10 13:59 A potential bug in lra-constraints.c for special_memory_constraint? Qing Zhao
2017-07-11  7:47 ` Eric Botcazou
2017-07-11 13:43   ` Qing Zhao
2017-07-11 19:00     ` Eric Botcazou
2017-07-11 19:10       ` Qing Zhao
2017-07-11 21:24         ` Eric Botcazou
2017-07-11 23:04           ` Qing Zhao
2017-07-11 23:19             ` Eric Botcazou
2017-07-12  0:40               ` David Miller
     [not found]                 ` <1B4A781A-504A-4816-9D0B-55F4385853BC@oracle.com>
2017-07-12  7:59                   ` Eric Botcazou
     [not found]                     ` <E96C34DC-7ABF-458B-A0DC-A79B278741F1@oracle.com>
2017-07-12 15:28                       ` David Miller
2017-07-12 15:40                         ` Qing Zhao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).