[llvm] [DemandedBits] Add div/rem support (PR #148853)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 25 08:49:00 PDT 2025


================
@@ -246,6 +246,20 @@ void DemandedBits::determineLiveOperandBits(
     else
       AB &= ~(Known.One & ~Known2.One);
     break;
+  case Instruction::SRem: {
+    // urem and udiv will be converted to and/lshr
+    // multiple times and early on. So, we don't
+    // need to calculate demanded-bits for those.
+    const APInt *DivAmnt;
+    if (match(UserI->getOperand(1), m_APInt(DivAmnt))) {
----------------
nikic wrote:

```suggestion
    if (match(UserI->getOperand(1), m_Power2(DivAmnt))) {
```
Then you don't need the separate check.

https://github.com/llvm/llvm-project/pull/148853


More information about the llvm-commits mailing list