From: Jakub Jelinek <jakub@redhat.com>
To: Sandra Loosemore <sandra@codesourcery.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
Nigel Stephens <nigel@mips.com>,
Guy Morrogh <guym@mips.com>, David Ung <davidu@mips.com>,
Thiemo Seufer <ths@mips.com>,
Mark Mitchell <mark@codesourcery.com>,
richard@codesourcery.com
Subject: Re: [committed] Re: PATCH: fine-tuning for can_store_by_pieces
Date: Sat, 25 Aug 2007 09:58:00 -0000 [thread overview]
Message-ID: <20070825073109.GK2063@devserv.devel.redhat.com> (raw)
In-Reply-To: <20070825065954.GJ2063@devserv.devel.redhat.com>
[-- Attachment #1: Type: text/plain, Size: 3273 bytes --]
On Sat, Aug 25, 2007 at 02:59:54AM -0400, Jakub Jelinek wrote:
> *************** store_expr (tree exp, rtx target, int ca
> *** 4507,4513 ****
> str_copy_len, builtin_strncpy_read_str,
> (void *) TREE_STRING_POINTER (exp),
> MEM_ALIGN (target),
> ! exp_len > str_copy_len ? 1 : 0);
> if (exp_len > str_copy_len)
> clear_storage (dest_mem, GEN_INT (exp_len - str_copy_len),
> BLOCK_OP_NORMAL);
> --- 4520,4527 ----
> str_copy_len, builtin_strncpy_read_str,
> (void *) TREE_STRING_POINTER (exp),
> MEM_ALIGN (target),
> ! exp_len > str_copy_len ? 1 : 0,
> ! false);
> if (exp_len > str_copy_len)
> clear_storage (dest_mem, GEN_INT (exp_len - str_copy_len),
> BLOCK_OP_NORMAL);
>
> This is wrong. You added the memsetp argument to store_by_pieces
> as the 6th, before the endp argument, but you are passing
> exp_len > str_copy_len ? 1 : 0 as memsetp and false as endp.
> This will certainly screw up say
> struct A { char a[20]; };
> void foo (void)
> {
> struct A a = { "abc" };
> bar (&a);
> }
> because in that case exp_len (20) is bigger than str_copy_len
> and so clear_storage is needed for the rest of the array.
> If we pass false == 0 as endp, it means the returned endp
> will point to the beginning of the array (&a.a[0]), rather
> than where store_by_pieces stopped.
Surprised this wasn't caught up by make check, I have committed following as
obvious. This new testcase at least on x86_64-linux and i686-linux
fails after your patch and no longer does after swapping the arguments.
Jakub
[-- Attachment #2: O --]
[-- Type: text/plain, Size: 1815 bytes --]
2007-08-25 Jakub Jelinek <jakub@redhat.com>
* expr.c (store_expr): Fix order of store_by_pieces arguments.
* gcc.dg/array-init-2.c: New test.
--- gcc/expr.c.jj 2007-08-25 09:06:46.000000000 +0200
+++ gcc/expr.c 2007-08-25 09:24:07.000000000 +0200
@@ -4519,9 +4519,8 @@ store_expr (tree exp, rtx target, int ca
dest_mem = store_by_pieces (dest_mem,
str_copy_len, builtin_strncpy_read_str,
(void *) TREE_STRING_POINTER (exp),
- MEM_ALIGN (target),
- exp_len > str_copy_len ? 1 : 0,
- false);
+ MEM_ALIGN (target), false,
+ exp_len > str_copy_len ? 1 : 0);
if (exp_len > str_copy_len)
clear_storage (dest_mem, GEN_INT (exp_len - str_copy_len),
BLOCK_OP_NORMAL);
--- gcc/testsuite/gcc.dg/array-init-2.c.jj 2007-08-25 09:23:19.000000000 +0200
+++ gcc/testsuite/gcc.dg/array-init-2.c 2007-08-25 09:17:39.000000000 +0200
@@ -0,0 +1,51 @@
+/* Test array initializion by store_by_pieces. */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+struct A { char c[10]; };
+extern void abort (void);
+
+void
+__attribute__((noinline))
+check (struct A * a, int b)
+{
+ const char *p;
+ switch (b)
+ {
+ case 0:
+ p = "abcdefghi";
+ break;
+ case 1:
+ p = "j\0\0\0\0\0\0\0\0";
+ break;
+ case 2:
+ p = "kl\0\0\0\0\0\0\0";
+ break;
+ case 3:
+ p = "mnop\0\0\0\0\0";
+ break;
+ case 4:
+ p = "qrstuvwx\0";
+ break;
+ default:
+ abort ();
+ }
+ if (__builtin_memcmp (a->c, p, 10) != 0)
+ abort ();
+}
+
+int
+main (void)
+{
+ struct A a = { "abcdefghi" };
+ check (&a, 0);
+ struct A b = { "j" };
+ check (&b, 1);
+ struct A c = { "kl" };
+ check (&c, 2);
+ struct A d = { "mnop" };
+ check (&d, 3);
+ struct A e = { "qrstuvwx" };
+ check (&e, 4);
+ return 0;
+}
next prev parent reply other threads:[~2007-08-25 7:32 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-15 17:15 Sandra Loosemore
2007-08-15 17:22 ` Andrew Pinski
2007-08-15 18:32 ` Sandra Loosemore
2007-08-15 19:53 ` Nigel Stephens
2007-08-15 19:58 ` Sandra Loosemore
2007-08-17 4:50 ` Mark Mitchell
2007-08-17 13:24 ` Sandra Loosemore
2007-08-17 18:55 ` Mark Mitchell
2007-08-16 8:34 ` Richard Sandiford
2007-08-16 19:41 ` Sandra Loosemore
2007-08-19 0:03 ` Sandra Loosemore
2007-08-20 8:22 ` Richard Sandiford
2007-08-20 23:38 ` Sandra Loosemore
2007-08-21 8:21 ` Richard Sandiford
2007-08-21 10:34 ` Nigel Stephens
2007-08-21 11:53 ` Richard Sandiford
2007-08-21 12:14 ` Nigel Stephens
2007-08-21 12:35 ` Richard Sandiford
2007-08-21 13:54 ` Sandra Loosemore
2007-08-21 14:22 ` Richard Sandiford
2007-08-21 20:39 ` Sandra Loosemore
2007-08-21 20:56 ` Richard Sandiford
2007-08-23 14:35 ` Sandra Loosemore
2007-08-23 14:44 ` Richard Sandiford
2007-08-25 5:35 ` [committed] " Sandra Loosemore
2007-08-25 9:18 ` Jakub Jelinek
2007-08-25 9:58 ` Jakub Jelinek [this message]
2007-08-25 14:30 ` gcc.c-torture/execute/20030221-1.c regressed with "fine-tuning for can_store_by_pieces" Hans-Peter Nilsson
2007-08-25 14:40 ` [committed] Re: PATCH: fine-tuning for can_store_by_pieces Sandra Loosemore
2007-08-24 22:06 ` Mark Mitchell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070825073109.GK2063@devserv.devel.redhat.com \
--to=jakub@redhat.com \
--cc=davidu@mips.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=guym@mips.com \
--cc=mark@codesourcery.com \
--cc=nigel@mips.com \
--cc=richard@codesourcery.com \
--cc=sandra@codesourcery.com \
--cc=ths@mips.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).