>From the alias-oracle walk we don't get here with valueized VUSE so valueize it before looking up an existing value, otherwise we'll ICE upon insertion which does valueize.
Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. Richard. 2018-03-27 Richard Biener <rguent...@suse.de> PR tree-optimization/85082 * tree-ssa-sccvn.c (vn_reference_lookup_or_insert_for_pieces): Valueize the VUSE. * gfortran.dg/pr85082.f90: New testcase. Index: gcc/tree-ssa-sccvn.c =================================================================== --- gcc/tree-ssa-sccvn.c (revision 258851) +++ gcc/tree-ssa-sccvn.c (working copy) @@ -1631,7 +1631,7 @@ vn_reference_lookup_or_insert_for_pieces vn_reference_s vr1; vn_reference_t result; unsigned value_id; - vr1.vuse = vuse; + vr1.vuse = vuse ? SSA_VAL (vuse) : NULL_TREE; vr1.operands = operands; vr1.type = type; vr1.set = set; Index: gcc/testsuite/gfortran.dg/pr85082.f90 =================================================================== --- gcc/testsuite/gfortran.dg/pr85082.f90 (nonexistent) +++ gcc/testsuite/gfortran.dg/pr85082.f90 (working copy) @@ -0,0 +1,14 @@ +! { dg-do compile } +! { dg-options "-Ofast" } +program p + real(4) :: a, b + integer(4) :: n, m + equivalence (a, n) + a = 1024.0 + m = 8 + a = 1024.0 + b = set_exponent(a, m) + n = 8 + a = f(a, n) + b = set_exponent(a, m) +end