gangche1 added a comment. We see in our IR that has addrspacecast before ptrtoint, which requires this optimization. Therefore suggest to add the handling of ptrtoint. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D72941/new/ https://reviews.llvm.org/D72941