Bug 2368616

Summary: simde mul_lane tests broken after clang-20.1.x upgrade on aarch64
Product: [Fedora] Fedora Reporter: Dominik 'Rathann' Mierzejewski <dominik>
Component: llvmAssignee: Tom Stellard <tstellar>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: dmalcolm, fedora-llvm-team, jakub, jchecahi, jistone, kkleine, npopov, scottt.tw, sergesanspaille, siddharth.kde, suraj.ghimire7, tbaeder, tstellar, tuliom
Target Milestone: ---Flags: npopov: mirror+
Target Release: ---   
Hardware: aarch64   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: ---
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2025-06-02 14:11:10 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2368384    

Description Dominik 'Rathann' Mierzejewski 2025-05-26 16:21:27 UTC
Description of problem:
simde tests started failing after clang was upgraded from 19.1.7 to 20.1.0. They're still failing with 20.1.3.

Version-Release number of selected component (if applicable):
clang-20.1.3-1.fc43

How reproducible:
Always.

Steps to Reproduce:
1. koji build --nowait --scratch rawhide git+https://src.fedoraproject.org/rpms/simde.git#cf07922a6ed8fe2d13482afa862e68b2ecc53385

Actual results:
+ /bin/time -f '=> [%E]' meson test -C build/clang-rpm -q --no-rebuild --print-errorlogs
▶  961/2002 mul_lane/vmul_laneq_s32               FAIL          
▶  962/2002 mul_lane/vmul_laneq_s32               FAIL          
 961/2002 arm/neon/mul_lane/emul/c                ERROR           1.49s   exit status 1
>>> MESON_TEST_ITERATION=1 MSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 ASAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1 MALLOC_PERTURB_=156 UBSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 /builddir/build/BUILD/simde-0.8.2-build/simde-0.8.2/build/clang-rpm/test/arm/neon/mul_lane-emul-c
――――――――――――――――――――――――――――――――――――― ✀  ―――――――――――――――――――――――――――――――――――――
stderr:
../../test/arm/neon/mul_lane.c:599: assertion failed: r[0] == simde_vld1_s32(test_vec[i].r)[0] (2076856 == 2076856)
(test program exited with status code 1)
――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
 962/2002 arm/neon/mul_lane/emul/cpp              ERROR           1.46s   exit status 1
>>> MESON_TEST_ITERATION=1 MSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 MALLOC_PERTURB_=128 ASAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1 UBSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 /builddir/build/BUILD/simde-0.8.2-build/simde-0.8.2/build/clang-rpm/test/arm/neon/mul_lane-emul-cpp
――――――――――――――――――――――――――――――――――――― ✀  ―――――――――――――――――――――――――――――――――――――
stderr:
test/arm/neon/mul_lane.cpp:599: assertion failed: r[0] == simde_vld1_s32(test_vec[i].r)[0] (2076856 == 2076856)
(test program exited with status code 1)
――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
Summary of Failures:
 961/2002 arm/neon/mul_lane/emul/c                ERROR           1.49s   exit status 1
 962/2002 arm/neon/mul_lane/emul/cpp              ERROR           1.46s   exit status 1
Ok:                 2000
Expected Fail:      0   
Fail:               2   
Unexpected Pass:    0   
Skipped:            0   
Timeout:            0   
Full log written to /builddir/build/BUILD/simde-0.8.2-build/simde-0.8.2/build/clang-rpm/meson-logs/testlog.txt
Command exited with non-zero status 2
=> [0:31.39]

Expected results:
+ /bin/time -f '=> [%E]' meson test -C build/clang-rpm -q --no-rebuild --print-errorlogs
Ok:                 2002
Expected Fail:      0   
Fail:               0   
Unexpected Pass:    0   
Skipped:            0   
Timeout:            0   
Full log written to /builddir/build/BUILD/simde-0.8.2-build/simde-0.8.2/build/clang-rpm/meson-logs/testlog.txt
=> [0:27.17]

Comment 1 Nikita Popov 2025-05-27 08:18:31 UTC
Still reproduces when using clang 20.1.5.

Comment 2 Tom Stellard 2025-05-27 17:29:47 UTC
I'll take a look at this one.

Comment 3 Nikita Popov 2025-05-28 08:34:54 UTC
I looked into this a bit yesterday and extracted this standalone reproducer: https://gist.github.com/nikic/08992eee1acb69d84cc75682ffe7ae4f

The issue requires ThinLTO to reproduce and opt-bisect points to LoopFullUnroll, but that's most likely a red herring.

Comment 4 Tom Stellard 2025-05-30 14:07:10 UTC
@npopov I've bisected it to https://github.com/llvm/llvm-project/commit/fe182ddf1f3daf55a86bbabeff40dda109bbbe91

Comment 5 Nikita Popov 2025-06-02 14:11:10 UTC
This is a bug in simde. https://github.com/simd-everywhere/simde/blob/51743e7920b6e867678cb50e9c62effe28f70b33/simde/arm/neon/mul_lane.h#L389 (and various other places) performs C signed integer multiplication, which is UB on overflow. These intrinsics are not supposed to have UB on overflow.

The issue was exposed because the loop was unrolled and all the constants were propagated.

I confirmed that adding (unsigned) casts to the code fixes the issue.

Comment 6 Nikita Popov 2025-06-02 14:14:28 UTC
Filed upstream issue: https://github.com/simd-everywhere/simde/issues/1295

Comment 7 Tulio Magno Quites Machado Filho 2025-06-13 13:59:34 UTC
*** Bug 2368547 has been marked as a duplicate of this bug. ***