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

via llvm-commits llvm-commits at lists.llvm.org
Sun May 19 22:08:35 PDT 2024


================
@@ -950,6 +950,41 @@ getKnownBitsFromAndXorOr(const Operator *I, const APInt &DemandedElts,
   return KnownOut;
 }
 
+static KnownBits computeKnownBitsForHorizontalOperation(
+    const Operator *I, const APInt &DemandedElts, unsigned Depth,
+    const SimplifyQuery &Q,
+    const std::function<KnownBits(const KnownBits &, const KnownBits &)>
+        KnownBitsFunc) {
+  APInt DemandedEltsLHS, DemandedEltsRHS;
+  getHorizontalDemandedElts(DemandedElts, DemandedEltsLHS, DemandedEltsRHS);
+
+  std::array<KnownBits, 2> KnownLHS;
+  for (unsigned Index = 0; Index < KnownLHS.size(); ++Index) {
+    if (!DemandedEltsLHS.isZero()) {
----------------
mskamp wrote:

I'm not sure I understand. In both cases, `KnownLHS[Index]` is initialized. Shouldn't both cases occur in the `hadd_extract` test cases? Shouldn't they fail if anything were uninitialized? At least, `valgrind --tool=memcheck` doesn't report any error when executing the tests.

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


More information about the llvm-commits mailing list