[llvm] Missing AArch64ISD::BICi handling (PR #76644)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 26 04:19:41 PST 2024


================
@@ -3416,10 +3416,15 @@ KnownBits SelectionDAG::computeKnownBits(SDValue Op, const APInt &DemandedElts,
       Known = KnownBits::mulhs(Known, Known2);
     break;
   }
-  case ISD::AVGCEILU: {
+  case ISD::AVGFLOORU:
+  case ISD::AVGCEILU:
+  case ISD::AVGFLOORS:
+  case ISD::AVGCEILS: {
     Known = computeKnownBits(Op.getOperand(0), DemandedElts, Depth + 1);
     Known2 = computeKnownBits(Op.getOperand(1), DemandedElts, Depth + 1);
-    Known = Known.zext(BitWidth + 1);
+    Known = (Opcode == ISD::AVGFLOORU || Opcode == ISD::AVGCEILU)
+                ? Known.zext(BitWidth + 1)
+                : Known.sext(BitWidth + 1);
     Known2 = Known2.zext(BitWidth + 1);
     KnownBits One = KnownBits::makeConstant(APInt(1, 1));
     Known = KnownBits::computeForAddCarry(Known, Known2, One);
----------------
RKSimon wrote:

Floor variants don't add the One:
```
bool IsCeil = Opcode == ISD::AVGCEILU || Opcode == ISD::AVGCEILS);
KnownBits Carry= KnownBits::makeConstant(APInt(1, IsCeil ? 1 : 0));
Known = KnownBits::computeForAddCarry(Known, Known2, Carry);
```

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


More information about the llvm-commits mailing list