[all-commits] [llvm/llvm-project] ae3670: [RISCV] Guard against out of bound shifts in expan...

Craig Topper via All-commits all-commits at lists.llvm.org
Thu Jul 24 17:28:10 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ae367028073f263c1b17faec70889fde36435c6d
      https://github.com/llvm/llvm-project/commit/ae367028073f263c1b17faec70889fde36435c6d
  Author: Craig Topper <craig.topper at sifive.com>
  Date:   2025-07-24 (Thu, 24 Jul 2025)

  Changed paths:
    M llvm/lib/Target/RISCV/RISCVISelLowering.cpp

  Log Message:
  -----------
  [RISCV] Guard against out of bound shifts in expandMul. (#150464)

Spotted while reviewing #150211. If we're multiplying by -3 in i32
MulAmt contains 4,294,967,293 since we zero extend to uint64_t. Adding 3
to this gives 0x100000000 which is a power of 2 and the log2 of that is
32, but we can't shift left by 32 in an i32.

Detect this case and skip the transform. We could use 0, but we don't
handle the case for i64 so this seemed more consistent.

Normally we don't hit this case because decomposeMulByConstant handles
it, but that's disabled by Xqciac. And after #150211 the code in
expandMul is now unreachable for this case.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list