The following fixes PR60635 - we fail to update re-gimplified stmts in gimple_regimplify_operands (or anywhere near its callers AFAIK). It seems coverage is quite low as this must otherwise have been noticed earlier ...
Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. Richard. 2014-03-25 Richard Biener <rguent...@suse.de> PR middle-end/60635 * gimplify-me.c (gimple_regimplify_operands): Update the re-gimplifed stmt. * gfortran.dg/lto/pr60635_0.f90: New testcase. * gfortran.dg/lto/pr60635_1.c: Likewise. Index: gcc/gimplify-me.c =================================================================== *** gcc/gimplify-me.c (revision 208789) --- gcc/gimplify-me.c (working copy) *************** gimple_regimplify_operands (gimple stmt, *** 315,320 **** --- 315,322 ---- gsi_insert_after (gsi_p, post_stmt, GSI_NEW_STMT); pop_gimplify_context (NULL); + + update_stmt (stmt); } Index: gcc/testsuite/gfortran.dg/lto/pr60635_1.c =================================================================== *** gcc/testsuite/gfortran.dg/lto/pr60635_1.c (revision 0) --- gcc/testsuite/gfortran.dg/lto/pr60635_1.c (working copy) *************** *** 0 **** --- 1,14 ---- + #include <stdint.h> + #include <stdbool.h> + + static bool littleendian=true; + + uint16_t bigendc16(union{uint16_t * n;uint8_t* b;}x){ + + if (!littleendian) return *x.n; + + uint16_t res = ((uint16_t)(x.b[1])<<0) | + ((uint16_t)(x.b[0])<<8); + return res; + } + Index: gcc/testsuite/gfortran.dg/lto/pr60635_0.f90 =================================================================== *** gcc/testsuite/gfortran.dg/lto/pr60635_0.f90 (revision 0) --- gcc/testsuite/gfortran.dg/lto/pr60635_0.f90 (working copy) *************** *** 0 **** --- 1,16 ---- + ! { dg-lto-do link } + program test + use iso_fortran_env + + interface + integer(int16) function bigendc16(x) bind(C) + import + integer(int16), intent(in) :: x + end function + end interface + + integer(int16) :: x16 = 12345 + x16 = bigendc16(x16) + print *,x16 + end program +