[PATCH] D93882: [SCEV] recognize logical and/or pattern

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 28 18:55:12 PST 2020


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

This patch makes SCEV recognize 'select A, B, false' and 'select A, true, B'.
This is a performance improvement that will be helpful after unsound select -> and/or transformation is removed, as discussed in D93065 <https://reviews.llvm.org/D93065>.

SCEV's answers for the select form should be a bit more conservative than the equivalent `and A, B` / `or A, B`.
Take this example: https://alive2.llvm.org/ce/z/NsP9ue .
To check whether it is valid for SCEV's computeExitLimit to return min(n, m) as ExactNotTaken value, I put llvm.assume at tgt.
It fails because the exit limit becomes poison if n is zero and m is poison. This is problematic if e.g. the exit value of i is replaced with min(n, m).
If and is used instead, this is okay: https://alive2.llvm.org/ce/z/K9rbJk . Hence the existing analysis is okay.
I put alive2 links at relevant tests.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93882

Files:
  llvm/include/llvm/Analysis/ScalarEvolution.h
  llvm/lib/Analysis/ScalarEvolution.cpp
  llvm/test/Analysis/ScalarEvolution/exit-count-select.ll
  llvm/test/Analysis/ScalarEvolution/trip-count-andor-selectform.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93882.313921.patch
Type: text/x-patch
Size: 21592 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201229/0df1b191/attachment-0001.bin>


More information about the llvm-commits mailing list