[PATCH] D110245: [ConstantFolding] Fold ptrtoint(gep i8 null, x) -> x

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 23 01:53:06 PDT 2021


lebedev.ri added inline comments.


================
Comment at: llvm/lib/Analysis/ConstantFolding.cpp:1353-1355
+        // zext/trunc the inttoptr to pointer size.
+        FoldedValue = ConstantExpr::getIntegerCast(
+            CE->getOperand(0), DL.getIntPtrType(CE->getType()), false);
----------------
I don't think this is correct.
In `int -> ptr -> int`, the width can be different at all three stages,
so i'd expect two sextOrTruncOrSelf casts back to back.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110245



More information about the llvm-commits mailing list