public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "hubicka at ucw dot cz" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug ipa/65028] [5 Regression] 450.soplex in SPEC CPU 2006 is miscompiled Date: Wed, 18 Feb 2015 21:16:00 -0000 [thread overview] Message-ID: <bug-65028-4-mnVa9u7oSB@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-65028-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65028 --- Comment #36 from Jan Hubicka <hubicka at ucw dot cz> --- Hi, I do not really see the reason for wrong code, but the merging logic seems weird for me. There is no merging done when we get two different alignments and also we seem to immediately drop lattice to bottom when the incomming parameter alignment has no .known bit set. This means we do pesimistic propagation. I..e in testcase void *b; __attribute__ ((noinline)) static void a (void *a) { memcpy (a,b,1000000); } static void aa (void *a) __attribute__ ((alias("a"))); tt(void) { int i[10000]; short c; aa(&c); a(i); } We end up with algnment unkonwn instead of a. (did not managed to reproduce the wrong alignment here). What about the following: Index: ipa-cp.c =================================================================== --- ipa-cp.c (revision 220789) +++ ipa-cp.c (working copy) @@ -1409,6 +1409,60 @@ propagate_context_accross_jump_function return ret; } +/* Decrease alignment info DEST to be at most CUR. */ + +static bool +decrease_alignment (ipa_alignment *dest, ipa_alignment cur) +{ + bool changed = false; + + if (!cur.known) + return false; + if (!dest->known) + { + *dest = cur; + return true; + } + if (dest->align == cur.align + && dest->misalign == cur.misalign) + return false; + + if (dest->align > cur.align) + { + dest->align = cur.align; + if (cur.align) + dest->misalign + = dest->misalign % cur.align; + changed = true; + } + if (dest->align && (dest->misalign != (cur.misalign % dest->align))) + { + int diff = abs (dest->misalign + - (cur.misalign % dest->align)); + dest->align = MIN (dest->align, (unsigned)diff & - diff); + if (dest->align) + dest->misalign + = dest->misalign % dest->align; + changed = true; + } + return changed; +} + +/* Increase alignment info DEST to be at least CUR. */ + +static bool +increase_alignment (ipa_alignment *dest, ipa_alignment cur) +{ + if (!dest->known) + return false; + if (!cur.known || dest->align < cur.align) + { + *dest = cur; + return true; + } + return false; +} + /* Propagate alignments across jump function JFUNC that is associated with edge CS and update DEST_LAT accordingly. */ @@ -1420,17 +1474,17 @@ propagate_alignment_accross_jump_functio if (alignment_bottom_p (dest_lat)) return false; - ipa_alignment cur; - cur.known = false; - if (jfunc->alignment.known) - cur = jfunc->alignment; - else if (jfunc->type == IPA_JF_PASS_THROUGH - || jfunc->type == IPA_JF_ANCESTOR) + ipa_alignment cur = jfunc->alignment; + + if (jfunc->type == IPA_JF_PASS_THROUGH + || jfunc->type == IPA_JF_ANCESTOR) { struct ipa_node_params *caller_info = IPA_NODE_REF (cs->caller); struct ipcp_param_lattices *src_lats; HOST_WIDE_INT offset = 0; int src_idx; + ipa_alignment incomming_cur; + bool ok = true; if (jfunc->type == IPA_JF_PASS_THROUGH) { @@ -1440,10 +1494,10 @@ propagate_alignment_accross_jump_functio if (op != POINTER_PLUS_EXPR && op != PLUS_EXPR && op != MINUS_EXPR) - goto prop_fail; + ok = false; tree operand = ipa_get_jf_pass_through_operand (jfunc); if (!tree_fits_shwi_p (operand)) - goto prop_fail; + ok = false; offset = tree_to_shwi (operand); } src_idx = ipa_get_jf_pass_through_formal_id (jfunc); @@ -1454,30 +1508,19 @@ propagate_alignment_accross_jump_functio offset = ipa_get_jf_ancestor_offset (jfunc); } - src_lats = ipa_get_parm_lattices (caller_info, src_idx); - if (!src_lats->alignment.known - || alignment_bottom_p (src_lats)) - goto prop_fail; - - cur = src_lats->alignment; - cur.misalign = (cur.misalign + offset) % cur.align; - } - - if (cur.known) - { - if (!dest_lat->alignment.known) + if (ok) { - dest_lat->alignment = cur; - return true; + src_lats = ipa_get_parm_lattices (caller_info, src_idx); + + incomming_cur = src_lats->alignment; + if (incomming_cur.known && incomming_cur.align) + incomming_cur.misalign = (incomming_cur.misalign + offset) + % incomming_cur.align; + increase_alignment (&cur, incomming_cur); } - else if (dest_lat->alignment.align == cur.align - && dest_lat->alignment.misalign == cur.misalign) - return false; } - prop_fail: - set_alignment_to_bottom (dest_lat); - return true; + return decrease_alignment (&dest_lat->alignment, cur); } /* If DEST_PLATS already has aggregate items, check that aggs_by_ref matches
next prev parent reply other threads:[~2015-02-18 21:16 UTC|newest] Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-02-11 20:23 [Bug ipa/65028] New: " hjl.tools at gmail dot com 2015-02-11 20:32 ` [Bug ipa/65028] " hubicka at gcc dot gnu.org 2015-02-12 13:28 ` rguenth at gcc dot gnu.org 2015-02-12 13:41 ` jamborm at gcc dot gnu.org 2015-02-13 17:02 ` jamborm at gcc dot gnu.org 2015-02-13 19:03 ` hubicka at ucw dot cz 2015-02-13 20:05 ` hubicka at gcc dot gnu.org 2015-02-13 20:06 ` hubicka at gcc dot gnu.org 2015-02-13 20:31 ` hubicka at gcc dot gnu.org 2015-02-16 17:35 ` jamborm at gcc dot gnu.org 2015-02-16 17:42 ` hjl.tools at gmail dot com 2015-02-16 18:40 ` hubicka at gcc dot gnu.org 2015-02-16 19:44 ` hjl.tools at gmail dot com 2015-02-16 21:20 ` hubicka at ucw dot cz 2015-02-17 16:23 ` hjl.tools at gmail dot com 2015-02-17 16:41 ` hjl.tools at gmail dot com 2015-02-17 17:03 ` hjl.tools at gmail dot com 2015-02-17 18:07 ` hjl.tools at gmail dot com 2015-02-17 18:14 ` jamborm at gcc dot gnu.org 2015-02-17 18:16 ` hubicka at gcc dot gnu.org 2015-02-17 18:20 ` hjl.tools at gmail dot com 2015-02-17 18:32 ` hjl.tools at gmail dot com 2015-02-17 19:09 ` hjl.tools at gmail dot com 2015-02-17 19:41 ` hjl.tools at gmail dot com 2015-02-17 20:37 ` hjl.tools at gmail dot com 2015-02-17 21:27 ` hjl.tools at gmail dot com 2015-02-17 22:32 ` hjl.tools at gmail dot com 2015-02-17 22:33 ` hjl.tools at gmail dot com 2015-02-17 23:52 ` hjl.tools at gmail dot com 2015-02-17 23:54 ` hubicka at ucw dot cz 2015-02-18 17:13 ` hjl.tools at gmail dot com 2015-02-18 17:32 ` hjl.tools at gmail dot com 2015-02-18 19:33 ` hjl.tools at gmail dot com 2015-02-18 20:09 ` hjl.tools at gmail dot com 2015-02-18 20:19 ` hubicka at ucw dot cz 2015-02-18 21:16 ` hubicka at ucw dot cz [this message] 2015-02-18 21:21 ` hjl.tools at gmail dot com 2015-02-18 21:41 ` jamborm at gcc dot gnu.org 2015-02-18 21:41 ` hubicka at ucw dot cz 2015-02-18 21:54 ` hjl.tools at gmail dot com 2015-02-18 21:54 ` hjl.tools at gmail dot com 2015-02-18 22:18 ` jamborm at gcc dot gnu.org 2015-02-18 22:33 ` hjl.tools at gmail dot com 2015-02-18 22:34 ` hjl.tools at gmail dot com 2015-02-18 22:46 ` jamborm at gcc dot gnu.org 2015-02-18 23:11 ` hjl.tools at gmail dot com 2015-02-18 23:11 ` hjl.tools at gmail dot com 2015-02-19 16:36 ` trippels at gcc dot gnu.org 2015-02-19 16:41 ` jamborm at gcc dot gnu.org 2015-02-19 18:46 ` jamborm at gcc dot gnu.org 2015-02-19 19:03 ` jamborm at gcc dot gnu.org 2015-02-19 19:37 ` hjl.tools at gmail dot com 2015-02-19 19:57 ` hubicka at ucw dot cz 2015-02-19 20:06 ` hjl.tools at gmail dot com 2015-02-19 23:32 ` hubicka at gcc dot gnu.org 2015-02-20 6:46 ` hubicka at ucw dot cz 2015-02-20 10:12 ` trippels at gcc dot gnu.org 2015-02-20 13:43 ` jamborm 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-65028-4-mnVa9u7oSB@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).