Skip to content

Commit

Permalink
shift -> multiplication strength reduction for uints
Browse files Browse the repository at this point in the history
  • Loading branch information
abadams committed Oct 5, 2015
1 parent 8153662 commit 78b6825
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Simplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2087,16 +2087,16 @@ class Simplify : public IRMutator {
Expr a = mutate(op->args[0]), b = mutate(op->args[1]);

int64_t ib = 0;
if (const_int(b, &ib)) {
if (const_int(b, &ib) || const_uint(b, (uint64_t *)(&ib))) {
Type t = op->type;

bool shift_left = op->name == Call::shift_left;
if (ib < 0) {
if (t.is_int() && ib < 0) {
shift_left = !shift_left;
ib = -ib;
}

if (ib < std::min(t.bits, 64)) {
if (ib >= 0 && ib < std::min(t.bits, 64)) {
ib = 1LL << ib;
b = make_const(t, ib);

Expand Down

0 comments on commit 78b6825

Please sign in to comment.