[PATCH] D111246: [WIP] Treat branch on poison as immediate UB

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 6 10:20:31 PDT 2021


reames created this revision.
reames added reviewers: regehr, nikic, lebedev.ri, nlopes, efriedma, hyeongyukim.
Herald added subscribers: asbirlea, bollu, hiraditya, mcrosier.
Herald added a reviewer: bollu.
reames requested review of this revision.
Herald added a project: LLVM.

The LangRef clearly states that branching on a poison value is immediate undefined behavior, but historically, we have not been consistent about implementing that interpretation in the optimizer.  Historically, we used (in some cases) a more relaxed model which essentially downgraded the poison to undef, and then looked for provable UB along the paths.  However, we've never been 100% consistent here.

At the moment, the last big blocker for this change is D106041 <https://reviews.llvm.org/D106041>.  Loop unswitching (in it's classic form) is incorrect with this change as it creates many "branch on poisons" when unswitching conditions originally unreachable within the loop.

This is posted mostly to show the benefit of this change optimization quality wise.  If reviewers are comfortable with this, I'd like to introduce the actual code change under an off by default flag (e.g. minimal test diffs) so that we can run performance tests in combination with the unswitch changes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111246

Files:
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/test/Analysis/ScalarEvolution/flags-from-poison.ll
  llvm/test/Analysis/ScalarEvolution/limit-depth.ll
  llvm/test/Analysis/ScalarEvolution/nsw.ll
  llvm/test/Analysis/ScalarEvolution/trip-count-negative-stride.ll
  llvm/test/Analysis/ScalarEvolution/trip-count-non-unit-stride.ll
  llvm/test/Transforms/AggressiveInstCombine/funnel.ll
  llvm/test/Transforms/AggressiveInstCombine/rotate.ll
  llvm/test/Transforms/LoopStrengthReduce/X86/expander-crashes.ll
  llvm/test/Transforms/LoopVectorize/consecutive-ptr-uniforms.ll
  llvm/test/Transforms/VectorCombine/AArch64/load-extractelement-scalarization.ll
  polly/test/DeLICM/pr41656.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111246.377591.patch
Type: text/x-patch
Size: 27811 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211006/9fe91e21/attachment.bin>


More information about the llvm-commits mailing list