This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug ipa/65028] [5 Regression] 450.soplex in SPEC CPU 2006 is miscompiled
- From: "hubicka at ucw dot cz" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 18 Feb 2015 21:16:50 +0000
- Subject: [Bug ipa/65028] [5 Regression] 450.soplex in SPEC CPU 2006 is miscompiled
- Auto-submitted: auto-generated
- References: <bug-65028-4 at http dot gcc dot gnu dot 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