[llvm] [LLVM][SVE][CodeGen] Fix incorrect isel for signed saturating instructions. (PR #88136)
Paul Walker via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 10 09:30:43 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) {
----------------
paulwalker-arm wrote:
I thought the same but whilst the switch is the same, the type of `Val` is different. For `SelectSVEAddSubImm` it is unsigned but here it is signed.
https://github.com/llvm/llvm-project/pull/88136
More information about the llvm-commits
mailing list