public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/25008]  New: problems with "S" constraint in asms
@ 2005-11-23 21:55 wilson at gcc dot gnu dot org
  2006-02-26 19:09 ` [Bug target/25008] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: wilson at gcc dot gnu dot org @ 2005-11-23 21:55 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3093 bytes --]

The following testcase compiles with gcc-4.0, but generates an error with
optimization with gcc-4.1.

int *
sub (int *i, int k)
{
  int j;
  for (j = 0; j < 16; j++)
    {
      asm volatile ("foo %0" : "=S" (*i));
      i += k;
    }
  return i;
}

aretha$ ./xgcc -B./ -O2 -S -da tmp.c
tmp.c: In function ‘sub’:
tmp.c:7: error: ‘asm’ operand requires impossible reload

This was broken by my patch that defined EXTRA_MEMORY_CONSTRAINT.
    http://gcc.gnu.org/ml/gcc-patches/2005-08/msg00714.html

I didn't have a testcase for that at the time, but now that I've run into
trouble, I went to the effort of creating of creating one.  It required adding
two letters, and deleting one.  The following testcase fails when compiled
without optimization with gcc-4.0.

int *
sub (int *i, int k)
{
  int j;
  for (j = 0; j < 16; j++)
    {
      asm volatile ("foo %0" : : "S" (*i));
      i += k;
    }
  return i;
}

aretha$ ./xgcc -B./ -S -da tmp2.c
tmp2.c: In function ‘sub’:
tmp2.c:7: error: impossible constraint in ‘asm’

The reason why defining EXTRA_MEMORY_CONSTRAINT fails for the first example is
because asm_operand_ok has code that says any memory operand is OK if
EXTRA_MEMORY_CONSTRAINT is true because it can be reloaded to fit.  This is
true in theory.  Unfortunately, reload doesn't know how to fix a MEM with a
POST_MODIFY address.  It fixes all MEMs that didn't quite match a MEM
constraint where an offsettable address is OK by reloading the address.
        else if (goal_alternative_matched[i] == -1
                 && goal_alternative_offmemok[i]
                 && MEM_P (recog_data.operand[i]))
          {
            operand_reloadnum[i]
              = push_reload (XEXP (recog_data.operand[i], 0), NULL_RTX,...
So if we have an operand (MEM (POST_MODIFY ...)) it is fixed by emitting an
insn (set (reg) (POST_MODIFY ...)) which fails to be recognized triggering the
error.  find_reloads_address knows how to fix this, but of course did not do
anything because this address is accepted by GO_IF_LEGITIMATE_ADDRESS.

The second example fails without EXTRA_MEMORY_CONSTRAINT defined because of
parse_input_constraint in stmt.c.  If EXTRA_CONSTRAINT_STR is not defined, then
it decides that no operand is acceptable.  When I posted the earlier patch, I
mentioned that it looked like we had a misplaced #endif, since the default here
should be to just accept all operands if we can't handle the constraint letter.

Unfortunately, taking a second look, I see that a parse_input_constraint change
doesn't work, because gimplify_asm_expr gives me the MEM operand I need only if
!allows_reg.

So it looks like I have to try to fix reload if I want this to work.


-- 
           Summary: problems with "S" constraint in asms
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: wilson at gcc dot gnu dot org
GCC target triplet: ia64-*-*


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


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

* [Bug target/25008] problems with "S" constraint in asms
  2005-11-23 21:55 [Bug target/25008] New: problems with "S" constraint in asms wilson at gcc dot gnu dot org
@ 2006-02-26 19:09 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-02-26 19:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2006-02-26 18:47 -------
Confirmed.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2006-02-26 18:47:23
               date|                            |


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


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

end of thread, other threads:[~2006-02-26 18:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-23 21:55 [Bug target/25008] New: problems with "S" constraint in asms wilson at gcc dot gnu dot org
2006-02-26 19:09 ` [Bug target/25008] " pinskia at gcc dot gnu dot org

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).