[llvm] [ValueTracking][X86] Compute KnownBits for phadd/phsub (PR #92429)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 10 03:41:00 PDT 2024
================
@@ -36953,6 +36934,34 @@ static void computeKnownBitsForPSADBW(SDValue LHS, SDValue RHS,
Known = Known.zext(64);
}
+static KnownBits computeKnownBitsForHorizontalOperation(
+ const SDValue Op, const APInt &DemandedElts, unsigned Depth,
+ unsigned OpIndexStart, const SelectionDAG &DAG,
+ const function_ref<KnownBits(const KnownBits &, const KnownBits &)>
+ KnownBitsFunc) {
+ APInt DemandedEltsLHS, DemandedEltsRHS;
+ getHorizDemandedEltsForFirstOperand(Op.getValueType().getSizeInBits(),
+ DemandedElts, DemandedEltsLHS,
+ DemandedEltsRHS);
+
+ const auto ComputeForSingleOpFunc =
+ [&DAG, Depth, KnownBitsFunc](const SDValue &Op, APInt &DemandedEltsOp) {
+ return KnownBitsFunc(
+ DAG.computeKnownBits(Op, DemandedEltsOp, Depth + 1),
+ DAG.computeKnownBits(Op, DemandedEltsOp << 1, Depth + 1));
+ };
+
+ if (!DemandedEltsLHS.isZero() && !DemandedEltsRHS.isZero()) {
+ return ComputeForSingleOpFunc(Op.getOperand(OpIndexStart), DemandedEltsLHS)
+ .intersectWith(ComputeForSingleOpFunc(Op.getOperand(OpIndexStart + 1),
+ DemandedEltsRHS));
+ }
+ if (!DemandedEltsLHS.isZero()) {
+ return ComputeForSingleOpFunc(Op.getOperand(OpIndexStart), DemandedEltsLHS);
+ }
----------------
RKSimon wrote:
(style) remove braces from single statement
https://github.com/llvm/llvm-project/pull/92429
More information about the llvm-commits
mailing list