HomePhabricator

[SCEV] recognize logical and/or pattern

Authored by aqjune on Dec 31 2020, 11:33 AM.

Description

[SCEV] recognize logical and/or pattern

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.

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 either n or m is constant, we can revive the analysis again. I added relevant tests and put alive2 links there.

If and is used instead, this is okay: https://alive2.llvm.org/ce/z/K9rbJk . Hence the existing analysis is sound.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D93882

Details

Committed
aqjuneDec 31 2020, 11:37 AM
Reviewer
nikic
Differential Revision
D93882: [SCEV] recognize logical and/or pattern
Parents
rG1a65b8c739a0: [Clang][Misc] Change run line in fragile test
Branches
Unknown
Tags
Unknown