If we can determine that a saturating add/sub will not overflow based on range analysis, convert it into a simple binary operation. This is a sibling transform to the existing with.overflow handling.
Details
- Reviewers
spatel lebedev.ri reames - Commits
- rG7bafae55c01d: Reapply [CVP] Simplify non-overflowing saturating add/sub
rL362263: Reapply [CVP] Simplify non-overflowing saturating add/sub
rG1e692d1777ae: [CVP] Simplify non-overflowing saturating add/sub
rL362242: [CVP] Simplify non-overflowing saturating add/sub
Diff Detail
Event Timeline
llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp | ||
---|---|---|
444 | Why not add a new statistic |
llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp | ||
---|---|---|
414–431 | This does preserve debugloc. In this case it's handled by the IRBuilder API. (The overflows.ll test also does a debugify check.) |
Check for integer type before trying to simplify, as LVI does not support vectors of integers. Also fix this for the with.overflow case -- we've recently started accepting vector args for those as well, but it looks like nobody ever ran the vector version through -O1 :)
(can you please commit @llvm.uadd.with.overflow.v2i32 + fix; the @llvm.uadd.sat.v2i8 test; and the patch as three separate commits?)
Hmm, right, not sure how this should work for vectors, especially non-splat ones. Treat each line separately?
llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp | ||
---|---|---|
414–431 | Great, thanks for checking! | |
418 | err, right, folding (: | |
llvm/test/Transforms/CorrelatedValuePropagation/overflows.ll | ||
831 | Hmm, great catch! |
llvm/test/Transforms/CorrelatedValuePropagation/overflows.ll | ||
---|---|---|
831 | Assuming you meant vector overflow here, then yes: This is only supported since recently -- more or less a side effect of having to deal with vector addo/subo in SDAG for saturating math expansion, so might as well allow in IR. But looks like nobody has actually used this yet, otherwise they would have definitely run into this issue :) |
holding