This works if Ptr has noundef: https://alive2.llvm.org/ce/z/S6yEwr
Alive2 does not support @llvm.ptrmask, but @llvm.ptrmask is
documented as equivilent to:
(getelementptr i8 Ptr, (sub (and (ptrtoint Ptr), Mask), (ptrtoint Ptr)))
See: https://llvm.org/docs/LangRef.html#llvm-ptrmask-intrinsic
Alive2 also doesn't handle inttoptr, so the proof compares:
define i64 @src_ptrtoint(ptr noundef %p, i64 %m) { %pi = ptrtoint ptr %p to i64 %pi_masked = and i64 %pi, %m ret i64 %pi_masked } define i64 @tgt_ptrtoint(ptr noundef %p, i64 %m) { %pi = ptrtoint ptr %p to i64 %pi_m = and i64 %pi, %m %pi_off = sub i64 %pi_m, %pi %pm = getelementptr i8, ptr %p, i64 %pi_off %pi_masked = ptrtoint ptr %pm to i64 ret i64 %pi_masked }
Which verifies