[PATCH] D51396: [Constant Hoisting] Hoisting Constant GEP Expressions

Z. Zheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 29 16:13:59 PDT 2018


zzheng added inline comments.


================
Comment at: lib/Transforms/Scalar/ConstantHoisting.cpp:407
+  int Cost = 3;;
+  if (Cost > TTI->getIntImmCost(Instruction::Add, 1, Offset, PtrIntTy)) {
+    ConstCandVecType &ExprCandVec = ConstGEPCandMap[BaseGV];
----------------
efriedma wrote:
> This still seems weird; we only hoist if the cost is less than 3?
We want to hoist when cost of hoisting is smaller than cost of not-hoisting.

Currently a constant GEP whose base pointer is a GV, is lowered to a CP entry. The initial value of Cost reflects cost of loading this CP entry.

If loading from CP is always more expensive than computing it by <base + offset>, perhaps we can get rid of this if condition?


Repository:
  rL LLVM

https://reviews.llvm.org/D51396





More information about the llvm-commits mailing list