You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rustc should detect and remove useless small array intializations.
This is C++ code:
#include <stdint.h>
typedef struct { int32_t arr[16]; } V;
V test(V a, V b) {
V res;
for (int i = 0; i < 16; i++)
res.arr[i] = a.arr[i] + b.arr[i];
return res;
}
Compiling it with Clang v.5 g++ -O3 -march=skylake-avx512
pub struct V { arr: [i32; 16] }
pub fn test(a: V, b: V) -> V {
let mut res = V { arr: [0; 16] };
for i in 0 .. 16 {
res.arr[i] = a.arr[i] + b.arr[i];
}
res
}
Rustc should detect and remove useless small array intializations.
This is C++ code:
Compiling it with Clang v.5
g++ -O3 -march=skylake-avx512
Similar Rustc code:
Not initializing the small result array:
Rust should remove the need to use mem::uninitialized() in such situations.
The text was updated successfully, but these errors were encountered: