Bug 23424 - cris.md rtl canonicalization bug
Summary: cris.md rtl canonicalization bug
Status: ASSIGNED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.1.0
: P2 normal
Target Milestone: ---
Assignee: Hans-Peter Nilsson
URL:
Keywords: patch
Depends on:
Blocks: 36482
  Show dependency treegraph
 
Reported: 2005-08-16 17:43 UTC by Hans-Peter Nilsson
Modified: 2009-10-09 09:04 UTC (History)
2 users (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: cris-axis-elf
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-08-16 17:44:29


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hans-Peter Nilsson 2005-08-16 17:43:32 UTC
For this code, at -O2:
extern char *x;
extern void foo (void);
void f (char *s, char *se, char *mp, char *y)
{
  while (s != se)
    {
      char *p;
      foo ();
      p = s + *mp;
      *y++ = *p;
      s = p;
    }

  x = s;
}
I get with LAST_UPDATED "Tue Aug 16 12:30:26 UTC 2005":
/tmp/b.c:15: error: insn does not satisfy its constraints:
(insn 74 26 29 2 (parallel [
            (set (reg:QI 13 r13)
                (mem:QI (plus:SI (sign_extend:SI (mem:QI (reg/v/f:SI 3 r3
[orig:31 mp ] [31]) [0 S1 A8]))
                        (reg/v/f:SI 0 r0 [orig:29 s ] [29])) [0 S1 A8]))
            (set (reg/v/f:SI 9 r9 [orig:28 p ] [28])
                (plus:SI (sign_extend:SI (mem:QI (reg/v/f:SI 3 r3 [orig:31 mp ]
[31]) [0 S1 A8]))
                    (reg/v/f:SI 0 r0 [orig:29 s ] [29])))
        ]) 18 {*mov_sideqi} (nil)
    (expr_list:REG_DEAD (reg/v/f:SI 0 r0 [orig:29 s ] [29])
        (nil)))
/tmp/b.c:15: internal compiler error: in copyprop_hardreg_forward_1, at
regrename.c:1578

At first sight, there's a cris.md bug that has been there forever:
the insn is supposed to match "*mov_side<mode>", but that can only happen
with help of the "%" commutative marker.  That marker isn't handled after
reload, and the insn is generated by the moverside peephole2 pattern.
All patterns *have* to be able to match whatever (canonical) RTL is generated
by the target after reload, without the commutativity marker.
So I'd say it's a target bug (the generated RTL is canonical) and IMHO arguably
also a documentation bug.  But there's more...
Comment 1 CVS Commits 2005-10-16 23:11:56 UTC
Subject: Bug 23424

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	hp@gcc.gnu.org	2005-10-16 23:11:50

Modified files:
	gcc            : ChangeLog 
	gcc/config/cris: cris.md 

Log message:
	PR target/23424
	* config/cris/cris.md ("*mov_side<mode>", "*mov_sidesisf")
	("*mov_side<mode>_mem", "*mov_sidesisf_mem", "*clear_side<mode>")
	("*ext_sideqihi", "*ext_side<mode>si", "*op_side<mode>")
	("*op_swap_side<mode>", "*extopqihi_side", "*extop<mode>si_side")
	("*extopqihi_swap_side", "*extop<mode>si_swap_side"): Have separate,
	swapped, alternatives for the R constraint.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.10166&r2=2.10167
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/cris/cris.md.diff?cvsroot=gcc&r1=1.38&r2=1.39

Comment 2 Hans-Peter Nilsson 2005-10-16 23:18:48 UTC
Patches at <URL:http://gcc.gnu.org/ml/gcc-patches/2005-10/msg00940.html>
and <URL:http://gcc.gnu.org/ml/gcc-patches/2005-10/msg00941.html>
(the latter has been committed).
Comment 3 Hans-Peter Nilsson 2005-10-16 23:26:51 UTC
For the "there's more" at the end of the PR description, see the first patch
of comment #2.
Comment 4 CVS Commits 2005-10-17 20:39:50 UTC
Subject: Bug 23424

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	hp@gcc.gnu.org	2005-10-17 20:39:46

Modified files:
	gcc            : ChangeLog 
	gcc/doc        : md.texi 

Log message:
	PR target/23424
	* md.texi (Modifiers) <%>: Clarify that % doesn't work
	after register allocation.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.10174&r2=2.10175
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/doc/md.texi.diff?cvsroot=gcc&r1=1.148&r2=1.149

Comment 5 Hans-Peter Nilsson 2005-11-04 21:20:27 UTC
Subject: Bug 23424

Author: hp
Date: Fri Nov  4 21:20:24 2005
New Revision: 106506

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=106506
Log:
	PR target/23424
	* config/cris/predicates.md ("cris_bdap_sign_extend_operand"):
	Disable.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/cris/predicates.md

Comment 6 Hans-Peter Nilsson 2005-11-04 21:24:23 UTC
Subject: Bug 23424

Author: hp
Date: Fri Nov  4 21:24:20 2005
New Revision: 106507

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=106507
Log:
	PR target/23424
	* gcc.dg/torture/pr23424-1.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/torture/pr23424-1.c
Modified:
    trunk/gcc/testsuite/ChangeLog

Comment 7 Hans-Peter Nilsson 2005-12-08 23:07:35 UTC
Subject: Bug 23424

Author: hp
Date: Thu Dec  8 23:07:31 2005
New Revision: 108255

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108255
Log:
	PR target/23424
	* recog.c (constrain_operands): Strip unary operators
	only ifndef KEEP_UNARY_OPERATORS_AT_CONSTRAINT_CHECKING.
	* reload.c (find_reloads): Ditto.
        * config/cris/cris.h (KEEP_UNARY_OPERATORS_AT_CONSTRAINT_CHECKING):
	Define.

Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/config/cris/cris.h
    branches/gcc-4_1-branch/gcc/recog.c
    branches/gcc-4_1-branch/gcc/reload.c

Comment 8 Hans-Peter Nilsson 2006-02-15 04:14:07 UTC
Subject: Bug 23424

Author: hp
Date: Wed Feb 15 04:14:02 2006
New Revision: 111017

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=111017
Log:
	PR target/23424
	* config/cris/predicates.md ("cris_bdap_sign_extend_operand"):
	Reenable.

Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/config/cris/predicates.md