aboutsummaryrefslogtreecommitdiffhomepage
path: root/ptx/src/translate.rs
diff options
context:
space:
mode:
authorAndrzej Janik <[email protected]>2021-08-01 19:20:08 +0200
committerAndrzej Janik <[email protected]>2021-08-01 19:20:08 +0200
commit4a71fefb8a3886277dba23a4ae17247bb5e2f2e5 (patch)
treea6f2d539f6a51e36c302fd6e64a87a225c617344 /ptx/src/translate.rs
parent8f68287b18afb1510ab055f0317a3f0dacce5d32 (diff)
downloadZLUDA-4a71fefb8a3886277dba23a4ae17247bb5e2f2e5.tar.gz
ZLUDA-4a71fefb8a3886277dba23a4ae17247bb5e2f2e5.zip
Change codegen for mul.wide
Diffstat (limited to 'ptx/src/translate.rs')
-rw-r--r--ptx/src/translate.rs42
1 files changed, 10 insertions, 32 deletions
diff --git a/ptx/src/translate.rs b/ptx/src/translate.rs
index 91e4237..5fea075 100644
--- a/ptx/src/translate.rs
+++ b/ptx/src/translate.rs
@@ -3798,8 +3798,8 @@ fn emit_mul_sint(
desc: &ast::MulSInt,
arg: &ast::Arg3<ExpandedArgParams>,
) -> Result<(), dr::Error> {
- let instruction_type = ast::ScalarType::from(desc.typ);
- let inst_type = map.get_or_add(builder, SpirvType::from(ast::ScalarType::from(desc.typ)));
+ let instruction_type = desc.typ;
+ let inst_type = map.get_or_add(builder, SpirvType::from(desc.typ));
match desc.control {
ast::MulIntControl::Low => {
builder.i_mul(inst_type, Some(arg.dst), arg.src1, arg.src2)?;
@@ -3816,25 +3816,14 @@ fn emit_mul_sint(
)?;
}
ast::MulIntControl::Wide => {
- let mul_ext_type = SpirvType::Struct(vec![
- SpirvScalarKey::from(instruction_type),
- SpirvScalarKey::from(instruction_type),
- ]);
- let mul_ext_type_id = map.get_or_add(builder, mul_ext_type);
- let mul = builder.s_mul_extended(mul_ext_type_id, None, arg.src1, arg.src2)?;
let instr_width = instruction_type.size_of();
let instr_kind = instruction_type.kind();
let dst_type = ast::ScalarType::from_parts(instr_width * 2, instr_kind);
let dst_type_id = map.get_or_add_scalar(builder, dst_type);
- struct2_bitcast_to_wide(
- builder,
- map,
- SpirvScalarKey::from(instruction_type),
- inst_type,
- arg.dst,
- dst_type_id,
- mul,
- )?;
+ let src1 = builder.s_convert(dst_type_id, None, arg.src1)?;
+ let src2 = builder.s_convert(dst_type_id, None, arg.src2)?;
+ builder.i_mul(dst_type_id, Some(arg.dst), src1, src2)?;
+ builder.decorate(arg.dst, spirv::Decoration::NoSignedWrap, []);
}
}
Ok(())
@@ -3865,25 +3854,14 @@ fn emit_mul_uint(
)?;
}
ast::MulIntControl::Wide => {
- let mul_ext_type = SpirvType::Struct(vec![
- SpirvScalarKey::from(instruction_type),
- SpirvScalarKey::from(instruction_type),
- ]);
- let mul_ext_type_id = map.get_or_add(builder, mul_ext_type);
- let mul = builder.u_mul_extended(mul_ext_type_id, None, arg.src1, arg.src2)?;
let instr_width = instruction_type.size_of();
let instr_kind = instruction_type.kind();
let dst_type = ast::ScalarType::from_parts(instr_width * 2, instr_kind);
let dst_type_id = map.get_or_add_scalar(builder, dst_type);
- struct2_bitcast_to_wide(
- builder,
- map,
- SpirvScalarKey::from(instruction_type),
- inst_type,
- arg.dst,
- dst_type_id,
- mul,
- )?;
+ let src1 = builder.u_convert(dst_type_id, None, arg.src1)?;
+ let src2 = builder.u_convert(dst_type_id, None, arg.src2)?;
+ builder.i_mul(dst_type_id, Some(arg.dst), src1, src2)?;
+ builder.decorate(arg.dst, spirv::Decoration::NoUnsignedWrap, []);
}
}
Ok(())