llvm / llvm/llvm-project

[Bug][ARM] vcvt_{s,u} NEON builtins lowered as plain fptosi/fptoui instead of saturating intrinsics

Open
#192,943 2 comments 0 reactions 1 assignee Claimed by @SavchenkoValeriy View on GitHub
backend:ARM miscompilation
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

ARM NEON intrinsics for FP-Int conversion are being lowered into non-saturating casts, but later selected as saturating instructions. However, if we have an optimization that uses UB for cast overflow case, we end up producing a different code.

Here is a small example of such a miscompile:
https://godbolt.org/z/f6cn17EoM

Running it produces 0 for -O0 and 251 for -O2. gcc correctly does not perform this optimization.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.