[llvm] [ARM]: codegen `llvm.roundeven.v*` (PR #141786)

Folkert de Vries via llvm-commits llvm-commits at lists.llvm.org
Thu May 29 07:21:37 PDT 2025


================
@@ -0,0 +1,78 @@
+; RUN: llc -mtriple=armv8 -mattr=+neon %s -o - | FileCheck %s
+
+; The llvm.arm.neon.frintn intrinsic should be auto-upgraded to the
+; target-independent roundeven intrinsic.
+
+define <4 x half> @frintn_4h(<4 x half> %A) nounwind {
+;CHECK-LABEL: frintn_4h:
+;CHECK: bl llvm.arm.neon.frintn.v4f16
+	%tmp3 = call <4 x half> @llvm.arm.neon.frintn.v4f16(<4 x half> %A)
----------------
folkertdev wrote:

switching `frint` to `vrint` works only for the `f32` types:


f16:
```
SplitVectorResult #0: t23: v4f16 = llvm.arm.neon.vrintn TargetConstant:i32<3805>, t21

LLVM ERROR: Do not know how to split the result of this operator!

PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
```

f64:
```
LLVM ERROR: Cannot select: intrinsic %llvm.arm.neon.vrintn
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /home/folkertdev/c/llvm-project/build/bin/llc -mtriple=armv8 -mattr=+neon /home/folkertdev/c/llvm-project/llvm/test/CodeGen/ARM/frintn.ll -o -
1.	Running pass 'Function Pass Manager' on module '/home/folkertdev/c/llvm-project/llvm/test/CodeGen/ARM/frintn.ll'.
2.	Running pass 'ARM Instruction Selection' on function '@frintn_2d'
```

I'm not sure what behavior they should have. We do define this for `v2f64`, but nothing for `f16` as far as I can tell.

```
    setOperationAction(ISD::FRINT, MVT::v2f64, Expand);
```

maybe something is missing here? https://github.com/llvm/llvm-project/blob/cb647ec4f89f6518a18492010b1957ebe3bb9e75/llvm/lib/Target/ARM/ARMInstrNEON.td#L7277-L7320

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


More information about the llvm-commits mailing list