[llvm] [AArch64][Codegen]Transform saturating smull to sqdmulh (PR #143671)

David Green via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 1 06:08:55 PDT 2025


================
@@ -0,0 +1,73 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; RUN: llc -mtriple=aarch64-none-elf < %s | FileCheck %s
+
+define <4 x i16> @saturating_4xi16(<4 x i16> %a, <4 x i16> %b) {
----------------
davemgreen wrote:

Can you add a test case for this, in case it goes wrong.
```
define <2 x i16> @saturating_2xi16(<2 x i16> %a, <2 x i16> %b) {
  %as = sext <2 x i16> %a to <2 x i32>
  %bs = sext <2 x i16> %b to <2 x i32>
  %m = mul <2 x i32> %bs, %as
  %sh = ashr <2 x i32> %m, splat (i32 15)
  %ma = tail call <2 x i32> @llvm.smin.v4i32(<2 x i32> %sh, <2 x i32> splat (i32 32767))
  %t = trunc <2 x i32> %ma to <2 x i16>
  ret <2 x i16> %t
}
```

Also I would add some test cases that were not expected to transform, like shifiting by 14 or having the wrong saturate constant. 

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


More information about the llvm-commits mailing list