[PATCH] D128670: [SimplifyCFG] teach simplifycfg not to introduce ptrtoint for NI pointers

Jameson Nash via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 6 12:04:05 PDT 2022


vtjnash added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/SimplifyCFG.cpp:483
+      DL.isNonIntegralPointerType(V->getType()))
     return CI;
 
----------------
nikic wrote:
> I realize that this is pre-existing, but I found the code structure here somewhat confusing. I think it would be more obvious to write this as two separate checks:
> 
> ```
> // Normal constant int.
> if (auto *CI = dyn_cast<ConstantInt>(V))
>   return CI;
> 
> // Only handle constant integral pointers in the following.
> if (!isa<Constant>(V) || !V->getType()->isPointerTy() ||
>     DL.isNonIntegralPointerType(V->getType()))
>   return nullptr;
> ```
I agree, if it was newly written, but also wasn't sure it warranted rearrangement, which would complicate the PR diff


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128670/new/

https://reviews.llvm.org/D128670



More information about the llvm-commits mailing list