https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91183
--- Comment #6 from Martin Sebor <msebor at gcc dot gnu.org> --- r273783 makes this work on x86_64 (and other targets with relaxed alignment) and sparc-solaris11 (and other strictly aligned targets) where the strlen call in g() still isn't folded. The difference is this between the following MEM_REF on x86_64: # _4 = PHI <3355185(2), 3552564(3)> MEM <unsigned int> [(char * {ref-all})&a] = _4; and this one on sparc-solaris11: # iftmp.0_2 = PHI <"456"(2), "123"(3)> MEM <unsigned char[4]> [(char * {ref-all})&a] = MEM <unsigned char[4]> [(char * {ref-all})iftmp.0_2]; _1 = __builtin_strlen (&a); It should be handled but isn't.