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

via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 5 12:24:14 PDT 2024


================
@@ -950,6 +950,39 @@ 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);
+
+  const auto ComputeForSingleOpFunc =
+      [Depth, &Q](const Value *Op, APInt &DemandedEltsOp,
+                  std::array<KnownBits, 2> &Known) {
+        for (unsigned Index = 0; Index < Known.size(); ++Index) {
+          if (!DemandedEltsOp.isZero()) {
+            Known[Index] = computeKnownBits(Op, DemandedEltsOp, Depth + 1, Q);
+          } else {
+            Known[Index] = KnownBits(getBitWidth(Op->getType(), Q.DL));
+            Known[Index].setAllZero();
----------------
goldsteinn wrote:

Yeah, I think thats clearer.

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


More information about the llvm-commits mailing list