Skip to content

[AArch64][GlobalISel] Add patterns for signed scalar extend intrinsics#201617

Merged
JoshdRod merged 1 commit into
llvm:mainfrom
JoshdRod:signed-xtn-fallback
Jun 5, 2026
Merged

[AArch64][GlobalISel] Add patterns for signed scalar extend intrinsics#201617
JoshdRod merged 1 commit into
llvm:mainfrom
JoshdRod:signed-xtn-fallback

Conversation

@JoshdRod
Copy link
Copy Markdown
Contributor

@JoshdRod JoshdRod commented Jun 4, 2026

Follow on from #201546
Add patterns for signed versions of scalar extend intrinsics as well.

Follow on from [llvm#201546])(llvm#201546).
Add patterns for signed versions of scalar extend intrinsics as well.
@llvmorg-github-actions
Copy link
Copy Markdown

@llvm/pr-subscribers-backend-aarch64

Author: Joshua Rodriguez (JoshdRod)

Changes

Follow on from #201546
Add patterns for signed versions of scalar extend intrinsics as well.


Full diff: https://github.com/llvm/llvm-project/pull/201617.diff

3 Files Affected:

  • (modified) llvm/lib/Target/AArch64/AArch64InstrInfo.td (+5)
  • (modified) llvm/lib/Target/AArch64/GISel/AArch64RegisterBankInfo.cpp (+2)
  • (modified) llvm/test/CodeGen/AArch64/arm64-arith-saturating.ll (+2-8)
diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
index 151cbd9bc5a7c..200808665c93e 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
@@ -6696,8 +6696,13 @@ defm UQXTN  : SIMDTwoScalarMixedBHS<1, 0b10100, "uqxtn", int_aarch64_neon_scalar
 defm USQADD : SIMDTwoScalarBHSDTied< 1, 0b00011, "usqadd", AArch64usqadd,
                                     int_aarch64_neon_usqadd>;
 
+// Scalar i32 -> i64 extend
 def : Pat<(i32 (int_aarch64_neon_scalar_uqxtn (i64 FPR64:$Rn))),
           (i32 (UQXTNv1i32 FPR64:$Rn))>;
+def : Pat<(i32 (int_aarch64_neon_scalar_sqxtn (i64 FPR64:$Rn))),
+          (i32 (SQXTNv1i32 FPR64:$Rn))>;
+def : Pat<(i32 (int_aarch64_neon_scalar_sqxtun (i64 FPR64:$Rn))),
+          (i32 (SQXTUNv1i32 FPR64:$Rn))>;
 
 // ssub_sat(0, R) -> sqneg(R)
 def : Pat<(v16i8 (ssubsat immAllZerosV, V128:$reg)),
diff --git a/llvm/lib/Target/AArch64/GISel/AArch64RegisterBankInfo.cpp b/llvm/lib/Target/AArch64/GISel/AArch64RegisterBankInfo.cpp
index ee9e57e705750..4767493e107b4 100644
--- a/llvm/lib/Target/AArch64/GISel/AArch64RegisterBankInfo.cpp
+++ b/llvm/lib/Target/AArch64/GISel/AArch64RegisterBankInfo.cpp
@@ -654,6 +654,8 @@ static bool isFPIntrinsic(const MachineRegisterInfo &MRI,
   case Intrinsic::aarch64_neon_sqneg:
   case Intrinsic::aarch64_neon_sqabs:
   case Intrinsic::aarch64_neon_scalar_uqxtn:
+  case Intrinsic::aarch64_neon_scalar_sqxtn:
+  case Intrinsic::aarch64_neon_scalar_sqxtun:
   case Intrinsic::aarch64_crypto_sha1h:
   case Intrinsic::aarch64_crypto_sha1c:
   case Intrinsic::aarch64_crypto_sha1p:
diff --git a/llvm/test/CodeGen/AArch64/arm64-arith-saturating.ll b/llvm/test/CodeGen/AArch64/arm64-arith-saturating.ll
index 15812d2d52d40..33c258d18ddcc 100644
--- a/llvm/test/CodeGen/AArch64/arm64-arith-saturating.ll
+++ b/llvm/test/CodeGen/AArch64/arm64-arith-saturating.ll
@@ -1,12 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc < %s -mtriple=arm64-eabi -mcpu=cyclone | FileCheck %s --check-prefixes=CHECK
-; RUN: llc < %s -mtriple=arm64-eabi -mcpu=cyclone -global-isel -global-isel-abort=2 2>&1 | FileCheck %s --check-prefixes=CHECK,CHECK-GI
-
-; CHECK-GI: warning: Instruction selection used fallback path for vqmovund
-; CHECK-GI-NEXT: warning: Instruction selection used fallback path for vqmovnd_s
-; CHECK-GI-NEXT: warning: Instruction selection used fallback path for sqxtn_ins
-; CHECK-GI-NEXT: warning: Instruction selection used fallback path for sqxtun_insext
-; CHECK-GI-NEXT: warning: Instruction selection used fallback path for saddluse
+; RUN: llc < %s -mtriple=arm64-eabi -mcpu=cyclone | FileCheck %s
+; RUN: llc < %s -mtriple=arm64-eabi -mcpu=cyclone -global-isel | FileCheck %s
 
 define i32 @qadds(<4 x i32> %b, <4 x i32> %c) nounwind readnone optsize ssp {
 ; CHECK-LABEL: qadds:

Copy link
Copy Markdown
Contributor

@davemgreen davemgreen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines +2 to +3
; RUN: llc < %s -mtriple=arm64-eabi -mcpu=cyclone | FileCheck %s
; RUN: llc < %s -mtriple=arm64-eabi -mcpu=cyclone -global-isel | FileCheck %s
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are the run lines being changed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because gisel no longer causes any fallbacks, we can remove the -global-isel-abort=2. This way, when there's any sort of fallback, the test fails.
I also removed the --check-prefixes flag, because gisel and sdag output is now the same.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ok, it wasn't obvious to me the default is enable. Nothing major but it would be clearer if the intent was explicit with -global-isel-abort=1

@JoshdRod JoshdRod merged commit ae3ef53 into llvm:main Jun 5, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants