[PATCH] D109093: [SCEVExpander] Simplify pointer overflow check

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 1 14:24:48 PDT 2021


nikic created this revision.
nikic added reviewers: reames, mkazantsev.
Herald added subscribers: javed.absar, hiraditya.
nikic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This is a followup to D104662 <https://reviews.llvm.org/D104662> to generate slightly nicer code for pointer overflow checks. Bypass expandAddToGEP and instead explicitly generate i8 GEPs. This saves some bitcasts and negates the value in a more obvious way. In particular, this prevents SCEV from looking through the umul.with.overflow, same as in the integer case.

The wrapping-pointer-ni.ll test deserves a comment: Previously, this generated a typed GEP which used the umul argument rather then the multiplication result. This results in more compact IR in that case, but effectively does the multiplication twice, the second one is just hidden in the GEP. Reusing the umulo result seems pretty reasonable to me.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109093

Files:
  llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
  llvm/test/Analysis/LoopAccessAnalysis/wrapping-pointer-ni.ll
  llvm/test/Transforms/LoopDistribute/scev-inserted-runtime-check.ll
  llvm/test/Transforms/LoopVersioning/wrapping-pointer-versioning.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109093.370056.patch
Type: text/x-patch
Size: 21087 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210901/f4bc19ce/attachment.bin>


More information about the llvm-commits mailing list