llvm-project/llvm/test/Analysis
Roman Lebedev 82fb4f4b22
[SCEV] Sequential/in-order `UMin` expression
As discussed in https://github.com/llvm/llvm-project/issues/53020 / https://reviews.llvm.org/D116692,
SCEV is forbidden from reasoning about 'backedge taken count'
if the branch condition is a poison-safe logical operation,
which is conservatively correct, but is severely limiting.

Instead, we should have a way to express those
poison blocking properties in SCEV expressions.

The proposed semantics is:
```
Sequential/in-order min/max SCEV expressions are non-commutative variants
of commutative min/max SCEV expressions. If none of their operands
are poison, then they are functionally equivalent, otherwise,
if the operand that represents the saturation point* of given expression,
comes before the first poison operand, then the whole expression is not poison,
but is said saturation point.
```
* saturation point - the maximal/minimal possible integer value for the given type

The lowering is straight-forward:
```
compare each operand to the saturation point,
perform sequential in-order logical-or (poison-safe!) ordered reduction
over those checks, and if reduction returned true then return
saturation point else return the naive min/max reduction over the operands
```
https://alive2.llvm.org/ce/z/Q7jxvH (2 ops)
https://alive2.llvm.org/ce/z/QCRrhk (3 ops)
Note that we don't need to check the last operand: https://alive2.llvm.org/ce/z/abvHQS
Note that this is not commutative: https://alive2.llvm.org/ce/z/FK9e97

That allows us to handle the patterns in question.

Reviewed By: nikic, reames

Differential Revision: https://reviews.llvm.org/D116766
2022-01-10 20:51:26 +03:00
..
AliasSet
AssumptionCache
BasicAA [Tests] Add elementtype attribute to indirect inline asm operands (NFC) 2022-01-06 14:23:51 +01:00
BlockFrequencyInfo
BranchProbabilityInfo [BPI] Look-up tables for non-loop branches. NFC. 2021-11-22 10:30:42 +00:00
CFLAliasAnalysis
CallGraph
CostModel [CostModel][X86] Update ROTL/ROTR vXi8/vXi16 costs on AVX512BW targets 2022-01-10 13:18:25 +00:00
CycleInfo Reapply CycleInfo: Introduce cycles as a generalization of loops 2021-12-10 14:36:43 +05:30
DDG
Delinearization
DemandedBits
DependenceAnalysis
DivergenceAnalysis
DominanceFrontier
Dominators Introduce NewPM .dot printers for DomTree 2022-01-05 23:25:40 +00:00
FunctionPropertiesAnalysis
GlobalsModRef
IRSimilarityIdentifier
IVUsers
LazyCallGraph
LazyValueAnalysis
LegacyDivergenceAnalysis
Lint
LoopAccessAnalysis [LoopVersioning] Move loop-versioning test to correct directory. 2022-01-07 14:35:13 +00:00
LoopCacheAnalysis/PowerPC
LoopInfo
LoopNestAnalysis
MemoryDependenceAnalysis
MemorySSA [NFC][llvm] Inclusive language: reword uses of sanity test and check 2021-11-25 07:21:42 -05:00
MustExecute
PhiValues
PostDominators
ProfileSummary
RegionInfo
ScalarEvolution [SCEV] Sequential/in-order `UMin` expression 2022-01-10 20:51:26 +03:00
ScopedNoAliasAA
StackSafetyAnalysis [stack-safety] Check SCEV constraints at memory instructions. 2021-11-23 15:29:23 -08:00
TypeBasedAliasAnalysis [funcattrs] Infer writeonly argument attribute [part 2] 2022-01-04 09:07:54 -08:00
ValueTracking
alias-analysis-uses.ll