[llvm] [LLVM][SVE][CodeGen] Fix incorrect isel for signed saturating instructions. (PR #88136)
Kerry McLaughlin via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 10 09:26:28 PDT 2024
================
@@ -4014,6 +4020,50 @@ bool AArch64DAGToDAGISel::SelectSVEAddSubImm(SDValue N, MVT VT, SDValue &Imm,
return false;
}
+bool AArch64DAGToDAGISel::SelectSVEAddSubSSatImm(SDValue N, MVT VT,
+ SDValue &Imm, SDValue &Shift) {
+ if (!isa<ConstantSDNode>(N))
+ return false;
+
+ SDLoc DL(N);
+ int64_t Val = cast<ConstantSDNode>(N)
+ ->getAPIntValue()
+ .trunc(VT.getFixedSizeInBits())
+ .getSExtValue();
+
+ // Signed saturating instructions treat their immediate operand as unsigned.
+ if (Val < 0)
+ return false;
+
+ switch (VT.SimpleTy) {
----------------
kmclaughlin-arm wrote:
This switch looks the same as the one in `SelectSVEAddSubImm` above, would it be possible to use the same function for the signed instructions and pass an extra `Signed` flag for checking `Val < 0`?
https://github.com/llvm/llvm-project/pull/88136
More information about the llvm-commits
mailing list