LLVM doesn't appear to use invariant.start/invariant.end to remove dead stores


Am I using invariant.start/invariant.end wrong here?

The linked godbolt contains LLVM IR that:

  1. calls invariant.start on 4 invariant pointers.

  2. loads from 2 of them.

  3. stores into a 5th pointer.

  4. loads from the remaining 2 pointers.

  5. stores into the same addresses of the 5th pointer.

  6. calls invariant.end on the 4 pointers.

I would expect LLVM to be able to eliminate “3.”.
Is LLVM not able to follow through the bitcasts and addrspace casts? I could try and come up with a cleaner example.

Also, is there a better place to ask questions like this?