While processing instructions in GVN, mark global variables and alloca instructions corresponding to each encountered invariant intrinsic call as indicating 'writeonce' memory locations that either have been written into or can be written into again (once). Then, while scanning instructions backwards looking for pointer dependencies for a given load instruction, be sure to temporarily disable or reset the markings, as appropriate.
This patch is a break-down of (corrected) D13606.