[llvm] [LLVM][SVE][CodeGen] Fix incorrect isel for signed saturating instructions. (PR #88136)

Paul Walker via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 11 03:53:41 PDT 2024


================
@@ -1059,6 +1059,20 @@ define <vscale x 16 x i8> @sqadd_b_lowimm(<vscale x 16 x i8> %a) {
   ret <vscale x 16 x i8> %out
 }
 
+; Immediate instruction form only supports positive values.
+define <vscale x 16 x i8> @sqadd_b_negimm(<vscale x 16 x i8> %a) {
+; CHECK-LABEL: sqadd_b_negimm:
+; CHECK:       // %bb.0:
+; CHECK-NEXT:    mov z1.b, #-1 // =0xffffffffffffffff
+; CHECK-NEXT:    sqadd z0.b, z0.b, z1.b
+; CHECK-NEXT:    ret
+  %elt = insertelement <vscale x 16 x i8> undef, i8 -1, i32 0
----------------
paulwalker-arm wrote:

Thinking about it a little more we should be able to invert negative constants along with the operation (i.e. "sqadd A, #-1" -> "sqsub A, #1".  The question is whether that is something I should do within this patch? Or whether we're happy to keep the bug fix separate?

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


More information about the llvm-commits mailing list