From: Uros Bizjak Date: Sat, 2 Jan 2010 14:32:23 +0000 (+0100) Subject: re PR target/42448 (Wrong code with _Complex char in structure) X-Git-Tag: releases/gcc-4.3.5~237 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e4a943eb06af58bfb490b305ffab5e156f1dae00;p=thirdparty%2Fgcc.git re PR target/42448 (Wrong code with _Complex char in structure) PR target/42448 * config/alpha/predicates.md (aligned_memory_operand): Return false for CQImode. (unaligned_memory_operand): Return true for CQImode. * config/alpha/alpha.c (get_aligned_mem): Assert that location doesn not cross aligned SImode word boundary. testsuite/ChangeLog: PR target/42448 * gcc.target/alpha/pr42448-1.c: New test. * gcc.target/alpha/pr42448-2.c: Ditto. From-SVN: r155568 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 4d020f8b4525..19276b510006 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2010-01-02 Uros Bizjak + + PR target/42448 + * config/alpha/predicates.md (aligned_memory_operand): Return false + for CQImode. + (unaligned_memory_operand): Return true for CQImode. + * config/alpha/alpha.c (get_aligned_mem): Assert that location + doesn not cross aligned SImode word boundary. + 2009-12-30 Ian Lance Taylor PR middle-end/42099 diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c index 3faeb0745fb4..06a6a27b24c0 100644 --- a/gcc/config/alpha/alpha.c +++ b/gcc/config/alpha/alpha.c @@ -1456,6 +1456,10 @@ get_aligned_mem (rtx ref, rtx *paligned_mem, rtx *pbitnum) else offset = disp & 3; + /* The location should not cross aligned word boundary. */ + gcc_assert (offset + GET_MODE_SIZE (GET_MODE (ref)) + <= GET_MODE_SIZE (SImode)); + /* Access the entire aligned word. */ *paligned_mem = widen_memory_access (ref, SImode, -offset); diff --git a/gcc/config/alpha/predicates.md b/gcc/config/alpha/predicates.md index e8379e73dc06..f7c231822a10 100644 --- a/gcc/config/alpha/predicates.md +++ b/gcc/config/alpha/predicates.md @@ -442,6 +442,10 @@ if (MEM_ALIGN (op) >= 32) return 1; + + if (mode == CQImode) + return 0; + op = XEXP (op, 0); /* LEGITIMIZE_RELOAD_ADDRESS creates (plus (plus reg const_hi) const_lo) @@ -470,6 +474,10 @@ if (MEM_ALIGN (op) >= 32) return 0; + + if (mode == CQImode) + return 1; + op = XEXP (op, 0); /* LEGITIMIZE_RELOAD_ADDRESS creates (plus (plus reg const_hi) const_lo) diff --git a/gcc/testsuite/gcc.target/alpha/pr42448-1.c b/gcc/testsuite/gcc.target/alpha/pr42448-1.c new file mode 100644 index 000000000000..4e2c376e39dc --- /dev/null +++ b/gcc/testsuite/gcc.target/alpha/pr42448-1.c @@ -0,0 +1,27 @@ +/* { dg-do run } */ +/* { dg-options "-mcpu=21064 -O0" } */ + +extern void abort (void); + +struct S2180 +{ + char t; + _Complex char u[2]; +}; + +struct S2180 s2180; + +int +main (void) +{ + volatile struct S2180 x; + + s2180.u[1] = 3 + 4i; + + x.u[1] = s2180.u[1]; + + if (x.u[1] != s2180.u[1]) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/alpha/pr42448-2.c b/gcc/testsuite/gcc.target/alpha/pr42448-2.c new file mode 100644 index 000000000000..aeebad2809b4 --- /dev/null +++ b/gcc/testsuite/gcc.target/alpha/pr42448-2.c @@ -0,0 +1,27 @@ +/* { dg-do run } */ +/* { dg-options "-mcpu=21064 -O0" } */ + +extern void abort (void); + +struct S2180 +{ + char t; + _Complex char u[4]; +}; + +struct S2180 s2180; + +int +main (void) +{ + volatile struct S2180 x; + + s2180.u[3] = 3 + 4i; + + x.u[3] = s2180.u[3]; + + if (x.u[3] != s2180.u[3]) + abort (); + + return 0; +}