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]

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.

+} + +void attribute ((noinline)) h(struct t tt) +{

+} + +void attribute ((noinline)) s(void); + +int main(int argc, char **argv) +{

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)

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

@@ -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)))]

brgds, H-P


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]