[llvm] [ValueTracking][X86] Compute KnownBits for phadd/phsub (PR #92429)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 4 10:11:58 PDT 2024


================
@@ -950,6 +950,43 @@ getKnownBitsFromAndXorOr(const Operator *I, const APInt &DemandedElts,
   return KnownOut;
 }
 
+static KnownBits computeKnownBitsForHorizontalOperation(
+    const Operator *I, const APInt &DemandedElts, unsigned Depth,
+    const SimplifyQuery &Q,
+    const function_ref<KnownBits(const KnownBits &, const KnownBits &)>
+        KnownBitsFunc) {
+  APInt DemandedEltsLHS, DemandedEltsRHS;
+  getHorizDemandedEltsForFirstOperand(Q.DL.getTypeSizeInBits(I->getType()),
+                                      DemandedElts, DemandedEltsLHS,
+                                      DemandedEltsRHS);
+
+  std::array<KnownBits, 2> KnownLHS;
+  for (unsigned Index = 0; Index < KnownLHS.size(); ++Index) {
+    if (!DemandedEltsLHS.isZero()) {
+      KnownLHS[Index] =
+          computeKnownBits(I->getOperand(0), DemandedEltsLHS, Depth + 1, Q);
+    } else {
+      KnownLHS[Index] = KnownBits(I->getType()->getScalarSizeInBits());
----------------
mskamp wrote:

Done.

There doesn't seem to be a similar helper in `X86ISelLowering.cpp`. Hence, I haven't changed the code over there.

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


More information about the llvm-commits mailing list