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

via llvm-commits llvm-commits at lists.llvm.org
Thu May 16 10:11:24 PDT 2024


================
@@ -1725,6 +1725,54 @@ static void computeKnownBitsFromOperator(const Operator *I,
       case Intrinsic::x86_sse42_crc32_64_64:
         Known.Zero.setBitsFrom(32);
         break;
+      case Intrinsic::x86_ssse3_phadd_d:
+      case Intrinsic::x86_ssse3_phadd_w:
+      case Intrinsic::x86_ssse3_phadd_d_128:
+      case Intrinsic::x86_ssse3_phadd_w_128:
+      case Intrinsic::x86_avx2_phadd_d:
+      case Intrinsic::x86_avx2_phadd_w: {
+        computeKnownBits(I->getOperand(0), DemandedElts, Known, Depth + 1, Q);
+        computeKnownBits(I->getOperand(1), DemandedElts, Known2, Depth + 1, Q);
----------------
goldsteinn wrote:

I'm not sure demandedelts is right to propagate here. I.e in your example of:
`[X1, X2], [Y1, Y2]` -> `[X1 + X2, Y1 + Y2]`. If you only demand the first element, you still need both `X1` and `X2` from operand 0, you just don't need either `Y1` or `Y2`.

This also appears to need to be changed for the rest of the impls.

Can you add some tests where the result is then shuffled/extracted from to test w/ DemandedElts as not all ones?

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


More information about the llvm-commits mailing list