summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ir/bits.h30
1 files changed, 11 insertions, 19 deletions
diff --git a/src/ir/bits.h b/src/ir/bits.h
index 4a20e5753..40bd8e545 100644
--- a/src/ir/bits.h
+++ b/src/ir/bits.h
@@ -176,7 +176,7 @@ Index getMaxBits(Expression* curr,
case RemSInt32: {
if (auto* c = binary->right->dynCast<Const>()) {
auto maxBitsLeft = getMaxBits(binary->left, localInfoProvider);
- // if maxBitsLeft is negative
+ // if left may be negative, the result may be negative
if (maxBitsLeft == 32) {
return 32;
}
@@ -199,12 +199,8 @@ Index getMaxBits(Expression* curr,
}
case OrInt32:
case XorInt32: {
- auto maxBits = getMaxBits(binary->right, localInfoProvider);
- // if maxBits is negative
- if (maxBits == 32) {
- return 32;
- }
- return std::max(getMaxBits(binary->left, localInfoProvider), maxBits);
+ return std::max(getMaxBits(binary->left, localInfoProvider),
+ getMaxBits(binary->right, localInfoProvider));
}
case ShlInt32: {
if (auto* shifts = binary->right->dynCast<Const>()) {
@@ -227,7 +223,7 @@ Index getMaxBits(Expression* curr,
case ShrSInt32: {
if (auto* shift = binary->right->dynCast<Const>()) {
auto maxBits = getMaxBits(binary->left, localInfoProvider);
- // if maxBits is negative
+ // if left may be negative, the result may be negative
if (maxBits == 32) {
return 32;
}
@@ -255,7 +251,7 @@ Index getMaxBits(Expression* curr,
case DivSInt64: {
if (auto* c = binary->right->dynCast<Const>()) {
int32_t maxBitsLeft = getMaxBits(binary->left, localInfoProvider);
- // if maxBitsLeft or right const value is negative
+ // if left or right const value is negative
if (maxBitsLeft == 64 || c->value.geti64() < 0) {
return 64;
}
@@ -275,7 +271,7 @@ Index getMaxBits(Expression* curr,
case RemSInt64: {
if (auto* c = binary->right->dynCast<Const>()) {
auto maxBitsLeft = getMaxBits(binary->left, localInfoProvider);
- // if maxBitsLeft is negative
+ // if left may be negative, the result may be negative
if (maxBitsLeft == 64) {
return 64;
}
@@ -293,17 +289,13 @@ Index getMaxBits(Expression* curr,
return 64;
}
case AndInt64: {
- auto maxBits = getMaxBits(binary->right, localInfoProvider);
- return std::min(getMaxBits(binary->left, localInfoProvider), maxBits);
+ return std::min(getMaxBits(binary->left, localInfoProvider),
+ getMaxBits(binary->right, localInfoProvider));
}
case OrInt64:
case XorInt64: {
- auto maxBits = getMaxBits(binary->right, localInfoProvider);
- // if maxBits is negative
- if (maxBits == 64) {
- return 64;
- }
- return std::max(getMaxBits(binary->left, localInfoProvider), maxBits);
+ return std::max(getMaxBits(binary->left, localInfoProvider),
+ getMaxBits(binary->right, localInfoProvider));
}
case ShlInt64: {
if (auto* shifts = binary->right->dynCast<Const>()) {
@@ -326,7 +318,7 @@ Index getMaxBits(Expression* curr,
case ShrSInt64: {
if (auto* shift = binary->right->dynCast<Const>()) {
auto maxBits = getMaxBits(binary->left, localInfoProvider);
- // if maxBits is negative
+ // if left may be negative, the result may be negative
if (maxBits == 64) {
return 64;
}