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