This is an attempt to fix https://bugs.llvm.org/show_bug.cgi?id=42436
I find easiest way to fix the issue is to not creating undefined value when adding a cast in SCEV expander. For my sample function (see bug description)
subtraction of results of two different ptrtoint instructions (with the same pointer) is correctly folded to zero by the backend. However there could be
potential issues, so any suggestions are highly welcome.