public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: target/4855: arm (thumb) backend generates illegal strb instruction
@ 2002-01-22 13:26 pb
  0 siblings, 0 replies; 2+ messages in thread
From: pb @ 2002-01-22 13:26 UTC (permalink / raw)
  To: avbidder, gcc-bugs, gcc-prs, nobody, pb

Synopsis: arm (thumb) backend generates illegal strb instruction

Responsible-Changed-From-To: unassigned->pb
Responsible-Changed-By: pb
Responsible-Changed-When: Tue Jan 22 13:26:22 2002
Responsible-Changed-Why:
    .
State-Changed-From-To: open->closed
State-Changed-By: pb
State-Changed-When: Tue Jan 22 13:26:22 2002
State-Changed-Why:
    Duplicate of PR 3218.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=4855


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

* target/4855: arm (thumb) backend generates illegal strb instruction
@ 2001-11-01 13:37 avbidder
  0 siblings, 0 replies; 2+ messages in thread
From: avbidder @ 2001-11-01 13:37 UTC (permalink / raw)
  To: gcc-gnats; +Cc: avbidder

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


>Number:         4855
>Category:       target
>Synopsis:       arm (thumb) backend generates illegal strb instruction
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Mon Nov 12 01:46:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Adrian von Bidder
>Release:        3.0.2
>Organization:
Acter AG, Zürich, Switzerland
>Environment:
System: Linux atlas 2.4.14 #2 Wed Nov 7 14:03:16 CET 2001 i686 unknown
Architecture: i686
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: arm-linux-elf
configured with: ../gcc-3.0.2.orig/configure --prefix=/home/avbidder/gcc-3 --target=arm-linux-elf --with-cpu=arm7tdmi --enable-checking
>Description:
gcc produces a 'strb rX, [sp, #offs]' instruction, which is not possible on the
ARM with thumb code (only low registers are allowed in str/ldr, since there are
only 3 bits of register address in the opcode.)

Of course, the assembler does complain.

Although the bug does not show up with the sample code and without optimizations
it's not an optimizer bug - the backend should not be able to generate this 
instruction at all.

>How-To-Repeat:
The bug is quite robust. It occurs with
arm-linux-elf-gcc -mthumb -fpic -mpic-register=r6 -O2
optionally, -O3, -msingle-pic-base, -mthumb-interwork and/or -g do not make the 
bug go away. 

$ arm-linux-elf-gcc -O2 -mthumb -fpic -mpic-register=r6 01.c
/tmp/ccd0bSpI.s: Assembler messages:
/tmp/ccd0bSpI.s:27: Error: byte or halfword not valid for base register

With
===
    strb    r3, [sp, #1]        !!!!!!
===
as the generated instruction . It should probably do something like
    mov rX, sp
    strb r3, [rX, #1]
where X is in [0..7]. Or use a low register to address the stack at all?


Boiled down as far as I could (it's an excerpt from regex.c in uclibc):
[cut down preprocessor output from the original file.]
===
typedef enum
{
  REG_NOERROR = 0,
  REG_NOMATCH,
  REG_BADPAT,
  REG_ECOLLATE,
  REG_ECTYPE,
  REG_EESCAPE,
  REG_ESUBREG,
  REG_EBRACK,
  REG_EPAREN,
  REG_EBRACE,
  REG_BADBR,
  REG_ERANGE,
  REG_ESPACE,
  REG_BADRPT,
  REG_EEND,
  REG_ESIZE,
  REG_ERPAREN
}
reg_errcode_t;

typedef unsigned long int reg_syntax_t;

extern int strcoll (const char *__s1, const char *__s2);

static reg_errcode_t
compile_range (p_ptr, pend, translate, syntax, b)
     const char **p_ptr, *pend;
     char *translate;
     reg_syntax_t syntax;
     unsigned char *b;
{
  unsigned this_char;

  const char *p = *p_ptr;
  reg_errcode_t ret;
  char range_start[2];
  char range_end[2];
  char ch[2];

//  if (p == pend)
//    return REG_ERANGE;

//  range_start[0] = p[-2];
//  range_start[1] = '\0';
//  range_end[0] = p[0];
//  range_end[1] = '\0';

//  (*p_ptr)++;


  ret = syntax & ((((((((((((((((((unsigned long int) 1) << 1) << 1) << 1) <<
			      1) << 1) << 1) << 1) << 1) << 1) << 1) << 1) <<
		      1) << 1) << 1) << 1) << 1) ? REG_ERANGE : REG_NOERROR;
  ch[1] = '\0';
  for (this_char = 0; this_char <= (unsigned char) -1; ++this_char)
    {
      ch[0] = this_char;
      if (strcoll (range_start, ch) <= 0 && strcoll (ch, range_end) <= 0)
	{
	  (b
	   [((unsigned
	      char) ((translate ? (char)
		      translate[(unsigned char) (this_char)] : (this_char))))
	    / 8] |=
	   1 <<
	   (((unsigned char) (translate ? (char)
			      translate[(unsigned char) (this_char)]
			      : (this_char))) % 8));
//	  ret = REG_NOERROR;
	}
    }

  return ret;
}
===

>Fix:
Don't use -On, n>1.

Probably the fix will be a modification in arm.md.

>Release-Note:
>Audit-Trail:
>Unformatted:


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

end of thread, other threads:[~2002-01-22 21:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-22 13:26 target/4855: arm (thumb) backend generates illegal strb instruction pb
  -- strict thread matches above, loose matches on Subject: below --
2001-11-01 13:37 avbidder

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