[PATCH] D98150: [ConstantFold] allow folding icmp of null and constexpr

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 7 12:22:41 PST 2021


spatel created this revision.
spatel added reviewers: lebedev.ri, nikic, reames, aqjune.
Herald added subscribers: dexonsmith, hiraditya, nemanjai, mcrosier.
spatel requested review of this revision.
Herald added a project: LLVM.

I noticed that we were not folding expressions like this:
icmp ult (constexpr), null
in https://llvm.org/PR49355, so we end up with extremely large icmp instructions as the constant expressions pile up on each other.

Unless I am misunderstanding, there is no potential to mis-fold an unsigned boundary condition with a zero/null, so this is just a falling through a crack in the pattern matching.

The more general case of comparisons of non-zero constants and constexpr are more tricky and may require the datalayout to know how to cast to different types, etc.


https://reviews.llvm.org/D98150

Files:
  llvm/lib/IR/ConstantFold.cpp
  llvm/test/CodeGen/PowerPC/pr46923.ll
  llvm/test/Transforms/InstCombine/vector_gep1-inseltpoison.ll
  llvm/test/Transforms/InstCombine/vector_gep1.ll
  llvm/test/Transforms/InstSimplify/ConstProp/icmp-null.ll
  llvm/test/Transforms/JumpThreading/thread-two-bbs.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98150.328890.patch
Type: text/x-patch
Size: 5437 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210307/fb3cfccb/attachment.bin>


More information about the llvm-commits mailing list