[CVP] Simplify SRem when constantrange abs(lhs) < abs(rhs)
authorluxufan <luxufan@iscas.ac.cn>
Tue, 20 Dec 2022 15:03:04 +0000 (23:03 +0800)
committerluxufan <luxufan@iscas.ac.cn>
Tue, 3 Jan 2023 14:51:12 +0000 (22:51 +0800)
commit5b25a0bcb14ba0b772a1d6b4ebbed5869a4a0fa7
treea67441c965dd141d5e20807efb90d66f5263c79d
parent419a21609444aa81e335254998f24099dc4a3c1f
[CVP] Simplify SRem when constantrange abs(lhs) < abs(rhs)

For `srem x, y`, if abs(constant range of x) less than abs(constant
range of y), we can simplify it as:
`srem x, y => x` if y is guaranteed to be positive.
'srem x, y => -x' if y is guaranteed to be negative.

Differential Revision: https://reviews.llvm.org/D140405
llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
llvm/test/Transforms/CorrelatedValuePropagation/srem.ll