Segher, Does BCD comparison return false when either operand is invalid coding? If yes, the result could be 3-way. We can check gt and eq bits for ge. We still can't use crnot to only check lt bit as there could be invalid coding. Also, do you think finite-math-only excludes invalid coding? Seems GCC doesn't clear define it.
Thanks. Gui Haochen On 2/6/2022 上午 6:05, Segher Boessenkool wrote: > Hi! > > On Tue, May 31, 2022 at 06:56:00PM -0500, Segher Boessenkool wrote: >> It's not clear to me how this can ever happen without finite_math_only? >> The patch is safe, sure, but it may the real problem is elsewhere. > > So, it is incorrect the RTL for our bcd{add,sub} insns uses CCFP at all. > > CCFP stands for the result of a 4-way comparison, regular float > comparison: lt gt eq un. But bcdadd does not have an unordered at all. > Instead, it has the result of a 3-way comparison (lt gt eq), and bit 3 > is set if an overflow happened -- but still exactly one of bits 0..2 is > set then! (If one of the inputs is an invalid number it sets bits 0..3 > to 0001 though.) > > So it would be much more correct and sensible to use regular integer > comparison results here, so, CC. > > Does that fix the problem? > > > Segher