[PATCH] D98147: [SCEV] Improve modelling for pointer constants

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 8 10:55:08 PST 2021


lebedev.ri added inline comments.


================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:1076
+    // Does the operand happen to be a (pointer) constant? If so, see if we can
+    // produce an integer constant (but *NOT* an ptr2int constant expression!).
+    if (auto *PC = dyn_cast<Constant>(U->getValue()))
----------------
Meinersbur wrote:
> typo is still there
> 
> A `GlobalValue`would but such a constant, but why handle it differently than a local value?
Because if we allow `ConstantExpr::getPtrToInt()` to return `ptrtoint` constant expression,
`getSCEV()` will immediately ask createSCEV() to model it as a SCEV expression,
which will result in calling `ScalarEvolution::getPtrToIntExpr()`,
which will then ask `ConstantExpr::getPtrToInt()`, which will then return `ptrtoint` constant expression,
`getSCEV()` will immediately ask createSCEV() to model it as a SCEV expression,
which will result in calling `ScalarEvolution::getPtrToIntExpr()`,
which will then ask `ConstantExpr::getPtrToInt()`, which will then return `ptrtoint` constant expression,
`getSCEV()` will immediately ask createSCEV() to model it as a SCEV expression,
which will result in calling `ScalarEvolution::getPtrToIntExpr()`,
which will then ask `ConstantExpr::getPtrToInt()`, which will then return `ptrtoint` constant expression,
`getSCEV()` will immediately ask createSCEV() to model it as a SCEV expression,
which will result in calling `ScalarEvolution::getPtrToIntExpr()`,
which will then ask `ConstantExpr::getPtrToInt()`, which will then return `ptrtoint` constant expression,
`getSCEV()` will immediately ask createSCEV() to model it as a SCEV expression,
which will result in calling `ScalarEvolution::getPtrToIntExpr()`,


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98147



More information about the llvm-commits mailing list