From: "Zebediah Figura (she/her)" Subject: Re: [PATCH vkd3d] vkd3d-shader/hlsl: Support casts between all numeric types on constant folding. Message-Id: Date: Mon, 17 Jan 2022 17:47:41 -0600 In-Reply-To: References: <658b9e98-ef2e-d928-8bb0-5da1664b92fc@codeweavers.com> <20211229145154.123397-1-fcasas@codeweavers.com> <5700bdee7b108779d2c5d0123fea6763@codeweavers.com> On 1/4/22 08:17, Giovanni Mascellani wrote: > Hi. > > On 30/12/21 22:55, Francisco Casas wrote: >> CONSTANT_OP2_FUNCTION(constant_value_sum,+) >> CONSTANT_OP2_FUNCTION(constant_value_sub,-) >> CONSTANT_OP2_FUNCTION(constant_value_mult,+) >> CONSTANT_OP2_FUNCTION(constant_value_neg,* (-1) + 0 *) /* horrid? */ >> CONSTANT_OP2_FUNCTION(constant_value_div,/) /* horrid? */ > > If you ask me, the neg thing is pretty horrid indeed, I'd avoid it. > Also, I'm pretty sure that multiplying a float by zero is not guaranteed > to give you zero (infinity * zero = NaN, I think, and I don't know about > NaN * zero), so depending on how you use it it might give wrong results. > If you want to go down that route, maybe it's better to add a > corresponding CONSTANT_OP1_FUNCTION. > > Also for the OP2 variants, notice that C doesn't define the results for > all the possible arguments given to these operations. For example > division by zero is undefined (and often results in a crash, in > particular I think it does on the architectures we target) and signed > overflow is undefined too (things like INT_MAX + INT_MAX, INT_MIN * -1, > etc). It seems that we don't use -fwrapv in vkd3d (differently from > Wine), which means that the compiler won't scramble to fix things up for > us. Where are you getting that Wine uses -fwrapv? I don't see any mention of that in the source.