aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Support/KnownBitsTest.cpp
diff options
context:
space:
mode:
authorgoldsteinn <35538541+goldsteinn@users.noreply.github.com>2024-11-05 07:03:37 -0800
committerGitHub <noreply@github.com>2024-11-05 09:03:37 -0600
commit877cb9a2edc9057d70321e436e5ea8ccc1a87140 (patch)
tree9084ecbc31bbf35bb126caa30e28ceb79b313f1d /llvm/unittests/Support/KnownBitsTest.cpp
parent15c7e9f9038e0c03c0dde1a8b85dd0f37072e832 (diff)
downloadllvm-877cb9a2edc9057d70321e436e5ea8ccc1a87140.zip
llvm-877cb9a2edc9057d70321e436e5ea8ccc1a87140.tar.gz
llvm-877cb9a2edc9057d70321e436e5ea8ccc1a87140.tar.bz2
[KnownBits] Make `{s,u}{add,sub}_sat` optimal (#113096)
Changes are: 1) Make signed-overflow detection optimal 2) For signed-overflow, try to rule out direction even if we can't totally rule out overflow. 3) Intersect add/sub assuming no overflow with possible overflow clamping values as opposed to add/sub without the assumption.
Diffstat (limited to 'llvm/unittests/Support/KnownBitsTest.cpp')
-rw-r--r--llvm/unittests/Support/KnownBitsTest.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/llvm/unittests/Support/KnownBitsTest.cpp b/llvm/unittests/Support/KnownBitsTest.cpp
index b16368d..ce0bf86 100644
--- a/llvm/unittests/Support/KnownBitsTest.cpp
+++ b/llvm/unittests/Support/KnownBitsTest.cpp
@@ -383,26 +383,22 @@ TEST(KnownBitsTest, BinaryExhaustive) {
"sadd_sat", KnownBits::sadd_sat,
[](const APInt &N1, const APInt &N2) -> std::optional<APInt> {
return N1.sadd_sat(N2);
- },
- /*CheckOptimality=*/false);
+ });
testBinaryOpExhaustive(
"uadd_sat", KnownBits::uadd_sat,
[](const APInt &N1, const APInt &N2) -> std::optional<APInt> {
return N1.uadd_sat(N2);
- },
- /*CheckOptimality=*/false);
+ });
testBinaryOpExhaustive(
"ssub_sat", KnownBits::ssub_sat,
[](const APInt &N1, const APInt &N2) -> std::optional<APInt> {
return N1.ssub_sat(N2);
- },
- /*CheckOptimality=*/false);
+ });
testBinaryOpExhaustive(
"usub_sat", KnownBits::usub_sat,
[](const APInt &N1, const APInt &N2) -> std::optional<APInt> {
return N1.usub_sat(N2);
- },
- /*CheckOptimality=*/false);
+ });
testBinaryOpExhaustive(
"shl",
[](const KnownBits &Known1, const KnownBits &Known2) {