Fix emit_small_mem{cpy,set} when size == 0 or access_size > 8
This commit is contained in:
@@ -598,6 +598,10 @@ impl<'a> FunctionBuilder<'a> {
|
|||||||
// Currently the result of guess work, not actual profiling.
|
// Currently the result of guess work, not actual profiling.
|
||||||
const THRESHOLD: u64 = 4;
|
const THRESHOLD: u64 = 4;
|
||||||
|
|
||||||
|
if size == 0 {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let access_size = greatest_divisible_power_of_two(size);
|
let access_size = greatest_divisible_power_of_two(size);
|
||||||
assert!(
|
assert!(
|
||||||
access_size.is_power_of_two(),
|
access_size.is_power_of_two(),
|
||||||
@@ -607,6 +611,13 @@ impl<'a> FunctionBuilder<'a> {
|
|||||||
access_size >= ::std::cmp::min(src_align, dest_align) as u64,
|
access_size >= ::std::cmp::min(src_align, dest_align) as u64,
|
||||||
"`size` is smaller than `dest` and `src`'s alignment value."
|
"`size` is smaller than `dest` and `src`'s alignment value."
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let (access_size, int_type) = if access_size > 8 {
|
||||||
|
(access_size, Type::int((access_size * 8) as u16).unwrap())
|
||||||
|
} else {
|
||||||
|
(8, types::I64)
|
||||||
|
};
|
||||||
|
|
||||||
let load_and_store_amount = size / access_size;
|
let load_and_store_amount = size / access_size;
|
||||||
|
|
||||||
if load_and_store_amount > THRESHOLD {
|
if load_and_store_amount > THRESHOLD {
|
||||||
@@ -615,7 +626,6 @@ impl<'a> FunctionBuilder<'a> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let int_type = Type::int((access_size * 8) as u16).unwrap();
|
|
||||||
let mut flags = MemFlags::new();
|
let mut flags = MemFlags::new();
|
||||||
flags.set_aligned();
|
flags.set_aligned();
|
||||||
|
|
||||||
@@ -669,6 +679,10 @@ impl<'a> FunctionBuilder<'a> {
|
|||||||
// Currently the result of guess work, not actual profiling.
|
// Currently the result of guess work, not actual profiling.
|
||||||
const THRESHOLD: u64 = 4;
|
const THRESHOLD: u64 = 4;
|
||||||
|
|
||||||
|
if size == 0 {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let access_size = greatest_divisible_power_of_two(size);
|
let access_size = greatest_divisible_power_of_two(size);
|
||||||
assert!(
|
assert!(
|
||||||
access_size.is_power_of_two(),
|
access_size.is_power_of_two(),
|
||||||
@@ -678,6 +692,13 @@ impl<'a> FunctionBuilder<'a> {
|
|||||||
access_size >= buffer_align as u64,
|
access_size >= buffer_align as u64,
|
||||||
"`size` is smaller than `dest` and `src`'s alignment value."
|
"`size` is smaller than `dest` and `src`'s alignment value."
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let (access_size, int_type) = if access_size > 8 {
|
||||||
|
(access_size, Type::int((access_size * 8) as u16).unwrap())
|
||||||
|
} else {
|
||||||
|
(8, types::I64)
|
||||||
|
};
|
||||||
|
|
||||||
let load_and_store_amount = size / access_size;
|
let load_and_store_amount = size / access_size;
|
||||||
|
|
||||||
if load_and_store_amount > THRESHOLD {
|
if load_and_store_amount > THRESHOLD {
|
||||||
@@ -689,7 +710,6 @@ impl<'a> FunctionBuilder<'a> {
|
|||||||
flags.set_aligned();
|
flags.set_aligned();
|
||||||
|
|
||||||
let ch = ch as u64;
|
let ch = ch as u64;
|
||||||
let int_type = Type::int((access_size * 8) as u16).unwrap();
|
|
||||||
let raw_value = if int_type == types::I64 {
|
let raw_value = if int_type == types::I64 {
|
||||||
(ch << 32) | (ch << 16) | (ch << 8) | ch
|
(ch << 32) | (ch << 16) | (ch << 8) | ch
|
||||||
} else if int_type == types::I32 {
|
} else if int_type == types::I32 {
|
||||||
|
|||||||
Reference in New Issue
Block a user