[llvm] [AMDGPU] Rework dot4 signedness checks (PR #68757)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 14 21:40:30 PST 2023
================
@@ -13056,32 +13023,74 @@ static bool isMul(const SDValue Op) {
Opcode == AMDGPUISD::MUL_I24);
}
-static std::optional<bool> checkSignedness(const SDValue &N,
- ByteProvider<SDValue> &Src0,
- ByteProvider<SDValue> &Src1) {
+static std::optional<bool>
+checkSignedness(const SDValue &N, ByteProvider<SDValue> &Src0,
+ ByteProvider<SDValue> &Src1, const SDValue &S0Op,
+ const SDValue &S1Op, const SelectionDAG &DAG) {
auto MulOpcode = N.getOpcode();
- std::optional<bool> IterIsSigned;
- // Both sides of the tree must have the same signedness semantics.
- if ((Src0.IsSigned != Src1.IsSigned) ||
- (Src0.IsSigned.value_or(false) != Src1.IsSigned.value_or(false)))
- return IterIsSigned;
- // If we have a MUL_U24 op with signed semantics, then fail.
- if (Src0.IsSigned.value_or(false) && MulOpcode == AMDGPUISD::MUL_U24)
- return IterIsSigned;
- // If we have a MUL_I24 op with unsigned semantics, then fail.
- if (!Src0.IsSigned.value_or(true) && MulOpcode == AMDGPUISD::MUL_I24)
- return IterIsSigned;
-
- bool TopLevelSignedness =
- MulOpcode == AMDGPUISD::MUL_I24 ||
- (MulOpcode == ISD::MUL && N.getNode()->getFlags().hasNoSignedWrap() &&
- !N.getNode()->getFlags().hasNoUnsignedWrap());
-
- // In cases where we are accumulating into an i8 (for v_dot4), the
- // ByteProvider will not have signedness info since the MSBs are dont-cares.
- // In this case, we simply use the TopLevelSignedness of the instruction.
- IterIsSigned = Src0.IsSigned.value_or(TopLevelSignedness);
- return IterIsSigned;
+
+ // We have previously matched the signedness semantics of dot4 for this
+ // iteration via ValueTracking
+ if (MulOpcode == AMDGPUISD::MUL_U24 || MulOpcode == AMDGPUISD::MUL_I24)
+ return MulOpcode == AMDGPUISD::MUL_I24;
----------------
arsenm wrote:
This should give the same result if you just let it fall through the computeKnownBits handling?
https://github.com/llvm/llvm-project/pull/68757
More information about the llvm-commits
mailing list