llvm-project/polly/include/polly
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
..
CodeGen Use nullptr instead of 0 or NULL (NFC) 2022-01-07 10:17:29 -08:00
Config
Support [SCEV] Sequential/in-order `UMin` expression 2022-01-10 20:51:26 +03:00
Canonicalization.h Take OptimizationLevel class out of Pass Builder 2021-07-29 21:57:23 -07:00
CodePreparation.h
DeLICM.h [Polly] Port DeLICM to the NewPM. 2021-02-09 23:56:19 -06:00
DeadCodeElimination.h [Polly][DCE] clang-format DeadCodeElimination.h. NFC. 2021-03-24 09:33:14 -05:00
DependenceInfo.h [Polly] Implement user-directed loop distribution/fission. 2021-09-23 21:11:01 -05:00
FlattenAlgo.h
FlattenSchedule.h
ForwardOpTree.h [Polly] Avoid "using namespace llvm" in public headers. NFC. 2021-02-10 20:58:33 -06:00
JSONExporter.h
LinkAllPasses.h [Polly] Remove support for code generated by gfortran+DragonEgg. 2021-10-14 14:12:06 -05:00
ManualOptimizer.h [Polly] Implement user-directed loop distribution/fission. 2021-09-23 21:11:01 -05:00
MatmulOptimizer.h [Polly] Move MatMul optimization into its own file. NFC. 2021-06-04 23:22:30 -05:00
Options.h
PolyhedralInfo.h
PruneUnprofitable.h [Polly] Port PruneUnprofitable to the NewPM. 2021-02-09 23:56:20 -06:00
RegisterPasses.h
ScheduleOptimizer.h [Polly] Move MatMul optimization into its own file. NFC. 2021-06-04 23:22:30 -05:00
ScheduleTreeTransform.h [Polly][SchedOpt] Account for prevectorization of multiple statements. 2021-12-23 14:06:41 -06:00
ScopBuilder.h [Polly] Remove support for code generated by gfortran+DragonEgg. 2021-10-14 14:12:06 -05:00
ScopDetection.h [Polly] Introduce caching for the isErrorBlock function. NFC. 2021-08-18 14:05:50 -05:00
ScopDetectionDiagnostic.h [Polly] Reject regions entered by an indirectbr/callbr. 2021-09-27 18:49:11 -05:00
ScopInfo.h [Polly][Isl] Use the function unsignedFromIslSize to manage a isl::size object. NFCI 2021-11-05 11:15:22 +01:00
ScopPass.h Fix bugprone argument comments. 2022-01-09 12:21:02 -08:00
Simplify.h [Polly] Hide Simplify implementation from header. NFC. 2021-02-10 22:11:52 -06:00
ZoneAlgo.h