Hans-Peter Nilsson - Committed: fix PR target/30665 (cris.md) (original) (raw)
This is the mail archive of the gcc-patches@gcc.gnu.orgmailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
- From: Hans-Peter Nilsson
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 5 Feb 2007 22:23:25 +0100
- Subject: Committed: fix PR target/30665 (cris.md)
I added a reduced version of the original test-case where the "and"-operation though this case doesn't trig on trunk, together with a contructed one which does. The test-cases are briefly examined to theoretically work for 16-bitters too. Not much to say about the wrong-code bug itself. Oh right; this is a good example of where optional names on peephole2's & Co. would be nice.
gcc: PR target/30665 * config/cris/cris.md ("*andsi_movu", "*andsi_clear", "*andhi_movu") ("*andhi_clear", andu (casesi+45)): For size-changed operand where memory is allowed, require !side_effects_p, not just !MEM_VOLATILE_P.
testsuite: PR target/30665 * gcc.dg/torture/pr30665-1.c, gcc.dg/torture/pr30665-2.c: New tests.
Index: gcc.dg/torture/pr30665-1.c
--- gcc.dg/torture/pr30665-1.c (revision 0) +++ gcc.dg/torture/pr30665-1.c (revision 0) @@ -0,0 +1,24 @@ +/* PR target/30665: bug in cris.md peephole2 condition. + Testcase for trunk. / +/ { dg-do run } */ + +extern void abort (void); +extern void exit (int); + +int attribute ((noinline)) f (unsigned *p, int *x) +{ + int y = *p++ & 0xfff; + *x++ = y; + *x = *p; + return y; +} + +int main (void) +{ + unsigned u[2] = { 0x3aad, 0x5ad1 }; + int x[2] = {17689, 23456}; + + if (f (u, x) != 0xaad || x[0] != 0xaad || x[1] != 0x5ad1) + abort (); + exit (0); +} Index: gcc.dg/torture/pr30665-2.c
--- gcc.dg/torture/pr30665-2.c (revision 0) +++ gcc.dg/torture/pr30665-2.c (revision 0) @@ -0,0 +1,57 @@ +/* PR target/30665: bug in cris.md peephole2 condition.
- Original reduced testcase (fails on 3.2.1 derivate, not on trunk). / +/ { dg-do run } */
- +extern void abort (void); +extern void exit (int);
- +struct t +{
- unsigned int a : 12;
- unsigned int b : 12;
- unsigned int dummy1 : 8; +};
- +struct area +{
- int xa;
- int xb; +};
- +struct c +{
- struct area ii; +};
- +static struct c c;
- +void attribute ((noinline)) g(int a) +{
- if (a != 79)
- abort ();
+} + +void attribute ((noinline)) h(struct t tt) +{
- if (tt.a != 20 || tt.b != 79)
- abort ();
+} + +void attribute ((noinline)) s(void); + +int main(int argc, char **argv) +{
- c.ii.xa = 20;
- c.ii.xb = 79;
- s();
- exit (0); +}
- +void attribute ((noinline)) s(void) +{
- struct t ii_x = { .a = c.ii.xa, .b = c.ii.xb };
- g(c.ii.xb);
- h(ii_x); +}
Index: cris.md
--- cris.md (revision 121608) +++ cris.md (working copy) @@ -1,5 +1,5 @@ ;; GCC machine description for CRIS cpu cores. -;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 +;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 ;; Free Software Foundation, Inc. ;; Contributed by Axis Communications.
@@ -2229,7 +2229,7 @@ (define_insn "*andsi_movu" (and:SI (match_operand:SI 1 "nonimmediate_operand" "%r,Q,To") (match_operand:SI 2 "const_int_operand" "n,n,n")))] "(INTVAL (operands[2]) == 255 || INTVAL (operands[2]) == 65535)
- && (GET_CODE (operands[1]) != MEM || ! MEM_VOLATILE_P (operands[1]))"
- && !side_effects_p (operands[1])" "movu.%z2 %1,%0" [(set_attr "slottable" "yes,yes,no")])
@@ -2238,7 +2238,7 @@ (define_insn "*andsi_clear" (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0,0,0") (match_operand:SI 2 "const_int_operand" "P,n,P,n,P,n")))] "(INTVAL (operands[2]) == -65536 || INTVAL (operands[2]) == -256)
- && (GET_CODE (operands[0]) != MEM || ! MEM_VOLATILE_P (operands[0]))"
- && !side_effects_p (operands[0])" "@ cLear.b %0 cLear.w %0 @@ -2317,7 +2317,7 @@ (define_insn "*andhi_movu" [(set (match_operand:HI 0 "register_operand" "=r,r,r") (and:HI (match_operand:HI 1 "nonimmediate_operand" "r,Q,To") (const_int 255)))]
- "GET_CODE (operands[1]) != MEM || ! MEM_VOLATILE_P (operands[1])"
- "!side_effects_p (operands[1])" "mOvu.b %1,%0" [(set_attr "slottable" "yes,yes,no")])
@@ -2325,7 +2325,7 @@ (define_insn "*andhi_clear" [(set (match_operand:HI 0 "nonimmediate_operand" "=r,Q,To") (and:HI (match_operand:HI 1 "nonimmediate_operand" "0,0,0") (const_int -256)))]
- "GET_CODE (operands[0]) != MEM || ! MEM_VOLATILE_P (operands[0])"
- "!side_effects_p (operands[0])" "cLear.b %0" [(set_attr "slottable" "yes,yes,no") (set_attr "cc" "none")]) @@ -4043,8 +4043,8 @@ (define_peephole2 ; andu (casesi+45) ;; don't do this for a mem-volatile access. "REGNO (operands[2]) == REGNO (operands[0]) && INTVAL (operands[3]) <= 65535 && INTVAL (operands[3]) >= 0
- && ! CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'I')
- && (GET_CODE (operands[1]) != MEM || ! MEM_VOLATILE_P (operands[1]))"
- && !CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'I')
- && !side_effects_p (operands[1])" ;; FIXME: CC0 valid except for M (i.e. CC_NOT_NEGATIVE). [(set (match_dup 0) (match_dup 4)) (set (match_dup 5) (match_dup 6))]
brgds, H-P
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |