From 13be142f978e6364596fb2eeeadd7f2adae28e15 Mon Sep 17 00:00:00 2001 From: Alexander Root Date: Thu, 13 Oct 2022 13:04:15 -0700 Subject: [PATCH] Fix DistributeShiftsAsMuls --- src/HexagonOptimize.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/HexagonOptimize.cpp b/src/HexagonOptimize.cpp index c4ecda2fe70d..8c8a189f0171 100644 --- a/src/HexagonOptimize.cpp +++ b/src/HexagonOptimize.cpp @@ -2172,13 +2172,17 @@ class DistributeShiftsAsMuls : public IRMutator { const Cast *cast_a = a.as(); bool is_widening_cast = cast_a && cast_a->type.bits() >= cast_a->value.type().bits() * 2; if (is_widening_cast || Call::as_intrinsic(a, {Call::widening_add, Call::widening_mul, Call::widening_sub})) { - return mutate(distribute(a, make_one(a.type()) << *const_b)); + const uint64_t const_m = 1ull << *const_b; + Expr b = make_const(a.type(), const_m); + return mutate(distribute(a, b)); } } } else if (op->is_intrinsic(Call::widening_shift_left)) { if (const uint64_t *const_b = as_const_uint(op->args[1])) { + const uint64_t const_m = 1ull << *const_b; + Expr b = make_const(op->type, const_m); Expr a = Cast::make(op->type, op->args[0]); - return mutate(distribute(a, make_one(a.type()) << *const_b)); + return mutate(distribute(a, b)); } } return IRMutator::visit(op);