[all-commits] [llvm/llvm-project] 8ce74e: [TargetLowering] Add support for more constants to...

Craig Topper via All-commits all-commits at lists.llvm.org
Wed Apr 8 19:48:02 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8ce74e79d9dfe65b408ade6b38558553878c60d4
      https://github.com/llvm/llvm-project/commit/8ce74e79d9dfe65b408ade6b38558553878c60d4
  Author: Craig Topper <craig.topper at sifive.com>
  Date:   2026-04-08 (Wed, 08 Apr 2026)

  Changed paths:
    M llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
    M llvm/test/CodeGen/ARM/funnel-shift.ll
    M llvm/test/CodeGen/Mips/funnel-shift.ll
    M llvm/test/CodeGen/PowerPC/funnel-shift.ll
    M llvm/test/CodeGen/X86/funnel-shift.ll
    M llvm/test/CodeGen/X86/i128-udiv.ll

  Log Message:
  -----------
  [TargetLowering] Add support for more constants to expandDIVREMByConstant. (#189286)

If we can find a chunk size k where 2^k mod divisor == -1, we can add
the even chunks and subtract the odd chunks. The resulting sum may be
negative, so we need to add 2^k + 1 (a multiple of divisor) for each odd
chunk to ensure the result is positive. We have enough extra bits
between the chunk size and HBitWidth to avoid overflow.

The idea here is similar to checking if a decimal number is divisible by
11. You can add the even digits and subtract the odd digits. If the
resulting sum is divisible by 11 the original number is divisible by 11.



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