public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jamborm at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/58041] Unaligned access to arrays in packed structure Date: Thu, 01 Aug 2013 16:48:00 -0000 [thread overview] Message-ID: <bug-58041-4-f2WrWwDZZ2@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-58041-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58041 --- Comment #9 from Martin Jambor <jamborm at gcc dot gnu.org> --- More specifically, if I am correct assuming that the MEM_REF replace_ref builds always accesses exactly the same memory as the previous access *expr does (and only the address is computed better) and that *expr is how the function accessed that memory before, then I think what you need is the following (untested, except that I know it seems to fix the testcase, at least the assembly looks very different :-) *** /tmp/heQHTs_gimple-ssa-strength-reduction.c Thu Aug 1 18:43:45 2013 --- gcc/gimple-ssa-strength-reduction.c Thu Aug 1 18:38:31 2013 *************** dump_incr_vec (void) *** 1728,1738 **** static void replace_ref (tree *expr, slsr_cand_t c) { ! tree add_expr = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (c->base_expr), ! c->base_expr, c->stride); ! tree mem_ref = fold_build2 (MEM_REF, TREE_TYPE (*expr), add_expr, ! double_int_to_tree (c->cand_type, c->index)); ! /* Gimplify the base addressing expression for the new MEM_REF tree. */ gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt); TREE_OPERAND (mem_ref, 0) --- 1728,1748 ---- static void replace_ref (tree *expr, slsr_cand_t c) { ! tree add_expr, mem_ref, acc_type = TREE_TYPE (*expr); ! unsigned HOST_WIDE_INT misalign; ! unsigned align; ! ! get_object_alignment_1 (*expr, &align, &misalign); ! if (misalign != 0) ! align = (misalign & -misalign); ! if (align < TYPE_ALIGN (acc_type)) ! acc_type = build_aligned_type (acc_type, align); ! ! add_expr = fold_build2 (POINTER_PLUS_EXPR, TREE_TYPE (c->base_expr), ! c->base_expr, c->stride); ! mem_ref = fold_build2 (MEM_REF, acc_type, add_expr, ! double_int_to_tree (c->cand_type, c->index)); ! /* Gimplify the base addressing expression for the new MEM_REF tree. */ gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt); TREE_OPERAND (mem_ref, 0)
next prev parent reply other threads:[~2013-08-01 16:48 UTC|newest] Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-08-01 7:26 [Bug middle-end/58041] New: " bernd.edlinger at hotmail dot de 2013-08-01 7:31 ` [Bug middle-end/58041] " bernd.edlinger at hotmail dot de 2013-08-01 9:09 ` mikpe at it dot uu.se 2013-08-01 11:36 ` mikpe at it dot uu.se 2013-08-01 11:51 ` mikpe at it dot uu.se 2013-08-01 13:26 ` wschmidt at gcc dot gnu.org 2013-08-01 16:18 ` wschmidt at gcc dot gnu.org 2013-08-01 16:23 ` jamborm at gcc dot gnu.org 2013-08-01 16:48 ` jamborm at gcc dot gnu.org [this message] 2013-08-01 17:27 ` jamborm at gcc dot gnu.org 2013-08-01 17:49 ` wschmidt at gcc dot gnu.org 2013-08-01 17:54 ` wschmidt at gcc dot gnu.org 2013-08-01 18:17 ` bernd.edlinger at hotmail dot de 2013-08-01 18:29 ` wschmidt at gcc dot gnu.org 2013-08-01 18:32 ` wschmidt at gcc dot gnu.org 2013-08-01 19:09 ` bernd.edlinger at hotmail dot de 2013-08-01 19:20 ` wschmidt at gcc dot gnu.org 2013-08-01 19:36 ` mikpe at it dot uu.se 2013-08-01 23:06 ` jamborm at gcc dot gnu.org 2013-08-02 15:22 ` wschmidt at gcc dot gnu.org 2013-08-02 15:28 ` wschmidt at gcc dot gnu.org 2013-08-02 15:54 ` ebotcazou at gcc dot gnu.org 2013-08-02 16:06 ` wschmidt at gcc dot gnu.org 2013-08-02 16:58 ` jamborm at gcc dot gnu.org 2013-08-02 17:12 ` wschmidt at gcc dot gnu.org 2013-08-02 18:07 ` wschmidt at gcc dot gnu.org 2013-08-03 8:31 ` bernd.edlinger at hotmail dot de 2013-08-05 17:43 ` jamborm at gcc dot gnu.org 2013-08-06 11:59 ` jamborm at gcc dot gnu.org 2013-08-06 14:24 ` bernd.edlinger at hotmail dot de 2013-08-06 15:18 ` jamborm at gcc dot gnu.org 2013-08-06 15:19 ` jamborm at gcc dot gnu.org 2013-08-06 15:33 ` bernd.edlinger at hotmail dot de 2013-08-06 15:56 ` bernd.edlinger at hotmail dot de 2013-08-06 16:06 ` jamborm at gcc dot gnu.org 2013-08-06 16:12 ` bernd.edlinger at hotmail dot de 2013-08-06 16:36 ` bernd.edlinger at hotmail dot de 2013-08-06 16:59 ` jamborm at gcc dot gnu.org 2013-08-06 17:07 ` bernd.edlinger at hotmail dot de 2013-08-06 17:37 ` jamborm at gcc dot gnu.org 2013-08-06 18:19 ` wschmidt at gcc dot gnu.org
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=bug-58041-4-f2WrWwDZZ2@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /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: linkBe 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).