[PATCH] Fix PR47743
Richard Guenther
rguenther@suse.de
Tue Feb 15 13:28:00 GMT 2011
This fixes PR47743.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
Richard.
2011-02-15 Richard Guenther <rguenther@suse.de>
PR tree-optimization/47743
* tree-ssa-pre.c (phi_translate_1): If we didn't get a value-number
for a non-type-compatible VN lookup bail out.
* gcc.dg/torture/pr47743.c: New testcase.
Index: gcc/tree-ssa-pre.c
===================================================================
*** gcc/tree-ssa-pre.c (revision 170127)
--- gcc/tree-ssa-pre.c (working copy)
*************** phi_translate_1 (pre_expr expr, bitmap_s
*** 1691,1696 ****
--- 1691,1702 ----
result = fold_build1 (VIEW_CONVERT_EXPR, ref->type, result);
converted = true;
}
+ else if (!result && newref
+ && !useless_type_conversion_p (ref->type, newref->type))
+ {
+ VEC_free (vn_reference_op_s, heap, newoperands);
+ return NULL;
+ }
if (result && is_gimple_min_invariant (result))
{
Index: gcc/testsuite/gcc.dg/torture/pr47743.c
===================================================================
*** gcc/testsuite/gcc.dg/torture/pr47743.c (revision 0)
--- gcc/testsuite/gcc.dg/torture/pr47743.c (revision 0)
***************
*** 0 ****
--- 1,22 ----
+ /* { dg-do compile } */
+
+ int
+ foo (void *x, int y)
+ {
+ long long a = 1, *b;
+ double *c;
+ if (y)
+ {
+ b = (long long *) x;
+ while (b)
+ a *= *b++;
+ }
+ else
+ {
+ c = (double *) x;
+ while (c)
+ a *= *c++;
+ }
+ return a;
+ }
+
More information about the Gcc-patches
mailing list