-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
portable simd: -Zmir-opt-level=3 causes LLVM ERROR #98016
Comments
Due to inlining of al@eggy rust % rustc +nightly ./src/test/codegen/simd-wide-sum.rs --edition=2021 -Zmir-opt-level=3 -Zvalidate-mir -Zfuel=simd_wide_sum=46
warning: optimization-fuel-exhausted: Inline Instance { def: Item(WithOptConstParam { did: DefId(2:23390 ~ core[a873]::core_simd::vector::{impl#0}::to_array), const_param_did: None }), substs: [u8, Const { ty: usize, val: Value(Scalar(0x0000000000000008)) }] } into MirSource { instance: Item(WithOptConstParam { did: DefId(0:10 ~ simd_wide_sum[31d5]::wider_reduce_into_iter), const_param_did: None }), promoted: None }
warning: 1 warning emitted
al@eggy rust % rustc +nightly ./src/test/codegen/simd-wide-sum.rs --edition=2021 -Zmir-opt-level=3 -Zvalidate-mir -Zfuel=simd_wide_sum=47
warning: optimization-fuel-exhausted: Inline Instance { def: Item(WithOptConstParam { did: DefId(2:8403 ~ core[a873]::iter::traits::iterator::Iterator::map), const_param_did: None }), substs: [std::array::IntoIter<u8, 8_usize>, u16, fn(u8) -> u16 {<u16 as std::convert::From<u8>>::from}] } into MirSource { instance: Item(WithOptConstParam { did: DefId(0:10 ~ simd_wide_sum[31d5]::wider_reduce_into_iter), const_param_did: None }), promoted: None }
Invalid bitcast
%6 = bitcast <8 x i8> %5 to [8 x i8]
in function wider_reduce_into_iter
LLVM ERROR: Broken function found, compilation aborted!
al@eggy rust % rustc +nightly --version --verbose
rustc 1.63.0-nightly (99930ac7f 2022-06-11)
binary: rustc
commit-hash: 99930ac7f8cbb5d9b319b2e2e92794fd6f24f556
commit-date: 2022-06-11
host: x86_64-apple-darwin
release: 1.63.0-nightly
LLVM version: 14.0.5 |
does the no_mangle attr have done kind of effect? can't check on mobile right now |
I think it's more likely the |
A slightly simplified example: #![crate_type = "lib"]
#![feature(repr_simd)]
#[repr(simd)]
pub struct Simd([u8; 8]);
fn to_array_inner<T>(x: Simd) -> [u8; 8] {
x.0
}
pub fn to_array_outer(x: Simd) -> [u8; 8] {
to_array_inner::<()>(x)
} It only arises when inlining a generic function (in this case |
The difference seems to be that #![crate_type = "lib"]
#![feature(repr_simd)]
#[repr(simd)]
pub struct Simd([u8; 8]);
pub fn to_array_outer(x: Simd) -> [u8; 8] {
let y = x;
y.0
} to force an extra move. As for why |
With
and without define i64 @_ZN7example14to_array_outer17h4eae74749e7c0538E(<8 x i8>* %x) unnamed_addr #0 !dbg !5 {
%0 = alloca [8 x i8], align 1
%y = load <8 x i8>, <8 x i8>* %x, align 8, !dbg !10
%1 = bitcast <8 x i8> %y to [8 x i8], !dbg !11
store [8 x i8] %1, [8 x i8]* %0, align 1, !dbg !11
%2 = bitcast [8 x i8]* %0 to i64*, !dbg !13
%3 = load i64, i64* %2, align 1, !dbg !13
ret i64 %3, !dbg !13
} |
It's interesting that the failure (in my example) required |
Indeed. It shouldn't affect the ABI. |
* add 4 ices rust-lang/rust#98432 rust-lang/rust#98250 rust-lang/rust#98171 rust-lang/rust#98016 * Update ices/98432.rs Co-authored-by: Yuki Okushi <jtitor@2k36.org>
The original no longer crashes since #96451, but #98016 (comment) still does |
Triage: The above mentioned example now compiles fine with the latest nightly, I guess #107449 is related. Marking as |
…li-obk Test simd-wide-sum for codegen error This adds the necessary test infrastructure to "build-pass" codegen tests, for the purpose of doing that for a single revision of a codegen test. When mir-opts are tested, the output may vary from the usual, and maybe for positive reasons... but we don't necessarily want to output such bad LLVMIR that LLVM starts crashing on it. Currently when enabling MIR opts at higher levels this LLVMIR is still emitted, but it was previously disabled for getting in mir-opt's way and as this new revision without `// [mir-opt3]build-pass` would make it more likely to, I would like to not see the testing for the actual results regress again just because it was bundled with an ICE check as well. This fixes rust-lang#98016
I tried this code:
code originally from
./src/test/codegen/simd-wide-sum.rs
Meta
rustc --version --verbose
:When compile with
-Zmir-opt-level=3
, there is aLLVM_ERROR
which does not occur with-Zmir-opt-level=2
rustc ./src/test/codegen/simd-wide-sum.rs --edition=2021 -Zmir-opt-level=3 -Zvalidate-mir
The text was updated successfully, but these errors were encountered: