https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84190
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jsm28 at gcc dot gnu.org --- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> --- This is caused by r239778. I probably thought it was harmless to drop since if we drop the TREE_ADDRESSABLE we're likely no longer expanding it as memory. But that's only true for the is_gimple_reg () case. Thus for vectors where we additionally need DECL_IS_GIMPLE_REG we already "broke" this earlier. Indeed with this rev. reverted I still see No longer having address taken: x No longer having address taken: y main: .LFB0: .cfi_startproc movapd gx(%rip), %xmm0 cmpeqpd gy(%rip), %xmm0 movq %xmm0, %rax for typedef double T __attribute__((vector_size(16))); static int equalfn (volatile T* x, volatile T* y); T gx, gy; int main () { T x = gx, y = gy; return equalfn (&x, &y); } static int equalfn (volatile T* x, volatile T* y) { return (*x == *y)[0]; } so we don't expand 'x' to memory or generate extra spills for main () { T y; T x; ... _8 ={v} MEM[(volatile T *)&x]; _9 ={v} MEM[(volatile T *)&y]; the theory is of course given you don't know the location of 'x' if it doesn't have its address taken 'volatile' cannot have any effect. This is what GCCs as old as GCC 4.8 produce for the vector case. So I'm somewhat inclined to _not_ fix this "bug". Otherwise to really preserve volatile semantics we have to preserve TREE_ADDRESSABLE also for !DECL_IS_GIMPLE_REG registers (or structs that might end up allocated not on the stack). Reversal to previous behavior would be Index: gcc/tree-ssa.c =================================================================== --- gcc/tree-ssa.c (revision 257382) +++ gcc/tree-ssa.c (working copy) @@ -1427,7 +1427,8 @@ non_rewritable_mem_ref_base (tree ref) if (! DECL_P (decl)) return NULL_TREE; if (! is_gimple_reg_type (TREE_TYPE (base)) - || VOID_TYPE_P (TREE_TYPE (base))) + || VOID_TYPE_P (TREE_TYPE (base)) + || TREE_THIS_VOLATILE (decl) != TREE_THIS_VOLATILE (base)) return decl; if ((TREE_CODE (TREE_TYPE (decl)) == VECTOR_TYPE || TREE_CODE (TREE_TYPE (decl)) == COMPLEX_TYPE)