On Mon Dec 12 16:36:55 2022 +0000, Giovanni Mascellani wrote:
Shouldn't you remove this part now? `elementwise_intrinsic_convert_args()` should have already taken care of everything, or am I missing something?
`elementwise_intrinsic_convert_args()` converts all arguments to the same common type by means of:
* Ensuring that matrices and vectors are not used at the same time as arguments. * Truncating vector (or matrix) arguments to the common shape. * Converting all arguments base type to the common base type.
without knowing of the intrinsic where it is used.
So it may be the case that this common type has base-type `int` if all the provided arguments have base-type `int`.
I did it this way because it is my understanding that not all intrinsic functions always return a `float` if all arguments are `int`, so it is responsibility of the function to do this conversion.
This often can be done converting the base-type of a single argument to float and let the uses of `add_binary_arithmetic_expr` propagate this conversion. It gets a little more complicated with intrinsics that take 3 arguments though such as `smoothstep()`, though.
It seems that indeed I can remove the calls to `expr_common_shape()` and some of the calls to `add_implicit_conversion()` here, or add a `bool convert_to_float` argument to `elementwise_intrinsic_convert_args()`. I will give it more thought, maybe I can write a shader to test where in the implementation of `smoothstep()` the conversion of `int` args to float takes place.