It's not generally safe to create new addrspace casts in the optimizer (since not all such addrspace casts are legal on any given target), so given that we don't currently have a generic way to check, bail instead of creating them.
This fixes a problem on an out of tree target where memcpyopt creates invalid addrspace casts in order to "cleverly" eliminate a memcpy.
How about more tests, where the sources are addrspacecasted to the same address space?