Commit 061407ec authored by Tapani Pälli's avatar Tapani Pälli
Browse files

nir: fix compiler warnings about implicit conversions



Instead of implicitly converting UINT64_MAX to operation destination
type, we explicitly set the correct max depending on type.

So instead of generating:

   uint8_t dst = (src0 + src1) < src0 ? (UINT64_MAX) : (src0 + src1);

we do:

   uint8_t dst = (src0 + src1) < src0 ? (UINT8_MAX) : (src0 + src1);

This clears following warnings during compilation:

  warning: implicit conversion from 'unsigned long' to 'uint1_t'
  warning: implicit conversion from 'unsigned long' to 'uint8_t'
  warning: implicit conversion from 'unsigned long' to 'uint16_t'
  warning: implicit conversion from 'unsigned long' to 'uint32_t'
Signed-off-by: Tapani Pälli's avatarTapani Pälli <tapani.palli@intel.com>
parent 41f76dd5
Pipeline #28252 passed with stages
in 10 minutes and 33 seconds
......@@ -327,7 +327,13 @@ struct ${type}${width}_vec {
${op.const_expr}
% else:
${output_type}_t dst = ${op.const_expr};
## Cast to correct type to avoid compiler warning about implicit
## conversion happening with UINT_MAX. Note special care on uint1_t.
<%
tmp_type = op.const_expr.replace('UINT_MAX', '(%s)' % (output_type.upper() + '_MAX'))
tmp_type = tmp_type.replace('UINT1_', 'UINT8_')
%>
${output_type}_t dst = ${tmp_type};
% endif
## Store the current component of the actual destination to the
......
......@@ -479,7 +479,7 @@ binop("iadd_sat", tint, commutative + associative, """
(src0 < src0 + src1 ? (1ull << (bit_size - 1)) : src0 + src1)
""")
binop("uadd_sat", tuint, commutative,
"(src0 + src1) < src0 ? UINT64_MAX : (src0 + src1)")
"(src0 + src1) < src0 ? UINT_MAX : (src0 + src1)")
binop("isub_sat", tint, "", """
src1 < 0 ?
(src0 - src1 < src0 ? (1ull << (bit_size - 1)) - 1 : src0 - src1) :
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment