[PATCH] D92203: [ConstantFold] Fold operations to poison if possible

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 28 09:27:33 PST 2020


aqjune marked an inline comment as done.
aqjune added a comment.

Yes, I can make a follow-up patch that does e.g., C / 0 -> poison soon. Thanks!



================
Comment at: llvm/test/Transforms/InstSimplify/ConstProp/poison.ll:114
+  %i4 = select i1 true, i8 poison, i8 %x
+  call void (...) @use(i1 %i1, i1 %i2, i8 %i3, i8 %i4, i8* getelementptr (i8, i8* poison, i64 1))
+  ret void
----------------
nikic wrote:
> aqjune wrote:
> > The GEP had to be written as a constant expr because InstSimplify's SimplifyGEPInst wasn't calling llvm::ConstantFoldGetElementPtr.
> It looks like it does invoke constant folding, but there is an earlier check for an undef base pointer, which also catches poison. When that is replaced to check poison first, it should work correctly.
I missed that it was calling `ConstantFoldConstant` at last. Thank you for the info.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92203



More information about the llvm-commits mailing list