Return u128 from bounds; form new_vec from iter chain

Copyright (c) 2021, Arm Limited
This commit is contained in:
dheaton-arm
2021-09-20 09:57:19 +01:00
parent 83c3bc5b9d
commit 3fc29f5f6c
2 changed files with 22 additions and 17 deletions

View File

@@ -782,16 +782,15 @@ where
Opcode::Snarrow | Opcode::Unarrow | Opcode::Uunarrow => {
let arg0 = extractlanes(&arg(0)?, ctrl_ty.lane_type())?;
let arg1 = extractlanes(&arg(1)?, ctrl_ty.lane_type())?;
let mut new_vec = SimdVec::new();
let new_type = ctrl_ty.split_lanes().unwrap();
let (min, max) = new_type.bounds(inst.opcode() == Opcode::Snarrow);
let mut min: V = Value::int(min, ctrl_ty.lane_type())?;
let mut max: V = Value::int(max, ctrl_ty.lane_type())?;
let mut min: V = Value::int(min as i128, ctrl_ty.lane_type())?;
let mut max: V = Value::int(max as i128, ctrl_ty.lane_type())?;
if inst.opcode() == Opcode::Uunarrow {
min = min.convert(ValueConversionKind::ToUnsigned)?;
max = max.convert(ValueConversionKind::ToUnsigned)?;
}
for mut lane in arg0.into_iter().chain(arg1) {
let narrow = |mut lane: V| -> ValueResult<V> {
if inst.opcode() == Opcode::Uunarrow {
lane = lane.convert(ValueConversionKind::ToUnsigned)?;
}
@@ -801,8 +800,13 @@ where
if inst.opcode() == Opcode::Unarrow || inst.opcode() == Opcode::Uunarrow {
lane = lane.convert(ValueConversionKind::ToUnsigned)?;
}
new_vec.push(lane);
}
Ok(lane)
};
let new_vec = arg0
.into_iter()
.chain(arg1)
.map(|lane| narrow(lane))
.collect::<ValueResult<Vec<_>>>()?;
assign(vectorizelanes(&new_vec, new_type)?)
}
Opcode::Sextend => assign(Value::convert(