[llvm] [LLVM] Improve the DemandedBits Analysis (PR #148853)

Panagiotis K via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 15 21:54:40 PDT 2025


================
@@ -246,6 +247,59 @@ void DemandedBits::determineLiveOperandBits(
     else
       AB &= ~(Known.One & ~Known2.One);
     break;
+  case Instruction::SRem:
+  case Instruction::URem:
+  case Instruction::UDiv:
+  case Instruction::SDiv: {
+    auto Opc = UserI->getOpcode();
+    auto IsDiv = Opc == Instruction::UDiv || Opc == Instruction::SDiv;
+    bool IsSigned = Opc == Instruction::SDiv || Opc == Instruction::SRem;
+    if (OperandNo == 0) {
+      const APInt *DivAmnt;
+      if (match(UserI->getOperand(1), m_APInt(DivAmnt))) {
+        uint64_t D = DivAmnt->getZExtValue();
----------------
karouzakisp wrote:

Done

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


More information about the llvm-commits mailing list