summaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorRhys Perry <[email protected]>2020-03-31 13:52:43 +0100
committerMarge Bot <[email protected]>2020-04-23 10:57:38 +0000
commit6d792989924ce79363f181462904fa46692a99b5 (patch)
treea7acd2c0fba87dc8a8bfbfb9aa0c330db3475d51 /src/compiler
parent715ef95700c06a09582744f3d873107728615b7f (diff)
nir/lower_bit_size: fix lowering of {imul,umul}_high
Signed-off-by: Rhys Perry <[email protected]> Reviewed-by: Erik Faye-Lund <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4387>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/nir/nir_lower_bit_size.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/compiler/nir/nir_lower_bit_size.c b/src/compiler/nir/nir_lower_bit_size.c
index 3ba63c81adc..100ac4864a5 100644
--- a/src/compiler/nir/nir_lower_bit_size.c
+++ b/src/compiler/nir/nir_lower_bit_size.c
@@ -70,8 +70,18 @@ lower_instr(nir_builder *bld, nir_alu_instr *alu, unsigned bit_size)
}
/* Emit the lowered ALU instruction */
- nir_ssa_def *lowered_dst =
- nir_build_alu(bld, op, srcs[0], srcs[1], srcs[2], srcs[3]);
+ nir_ssa_def *lowered_dst = NULL;
+ if (op == nir_op_imul_high || op == nir_op_umul_high) {
+ assert(dst_bit_size * 2 <= bit_size);
+ nir_ssa_def *lowered_dst = nir_imul(bld, srcs[0], srcs[1]);
+ if (nir_op_infos[op].output_type & nir_type_uint)
+ lowered_dst = nir_ushr(bld, lowered_dst, nir_imm_int(bld, dst_bit_size));
+ else
+ lowered_dst = nir_ishr(bld, lowered_dst, nir_imm_int(bld, dst_bit_size));
+ } else {
+ lowered_dst = nir_build_alu(bld, op, srcs[0], srcs[1], srcs[2], srcs[3]);
+ }
+
/* Convert result back to the original bit-size */
nir_alu_type type = nir_op_infos[op].output_type;