On Wed, Aug 10, 2022 at 12:03:16PM -0500, Segher Boessenkool wrote: > On Wed, Aug 10, 2022 at 02:23:27AM -0400, Michael Meissner wrote: > > On Fri, Aug 05, 2022 at 01:19:05PM -0500, Segher Boessenkool wrote: > > > On Thu, Jul 28, 2022 at 12:43:49AM -0400, Michael Meissner wrote: > > > > These patches lay the foundation for a set of follow-on patches that > > > > will > > > > change the internal handling of 128-bit floating point types in GCC. > > > > In the > > > > future patches, I hope to change the compiler to always use KFmode for > > > > the > > > > explicit _Float128/__float128 types, to always use TFmode for the long > > > > double > > > > type, no matter which 128-bit floating point type is used, and IFmode > > > > for the > > > > explicit __ibm128 type. > > > > > > Making TFmode different from KFmode and IFmode is not an improvement. > > > NAK. > > > > First of all, it already IS different from KFmode and IFmode, as we've > > talked > > about. > > It always is the same as either IFmode or KFmode in the end. It is a > separate mode, yes, because generic code always wants to use TFmode. > > > I'm trying to clean this mess up. Having explicit __float128's being > > converted to TFmode if -mabi=ieeelongdouble is just as bad, and it means > > that > > _Float128 and __float128 are not the same type. > > What do types have to do with this at all?
I believe the issue is with these two tests: gcc.dg/torture/float128-nan.c gcc.target/powerpc/nan128-1.c In particular, both use nansq to create a signaling NaN. The nansq function is defined as nansf128 (i.e. it returns a _Float128 type). However, at present, __float128 uses the long double type if the -mabi=ieeelongdouble option is used, not the _Float128 type. Even though these both use TFmode in that scenario, the gimple code sees a _Float128 type that is stored into a long double type. The machine independent support sees that you are changing types, and it silently converts the signaling NaN into a quiet NaN. An earlier patch was to just change nanq and nansq to resolve to nanl and nansl in the case -mabi=ieeelongdouble, which you did not like. In looking at it, I now believe that the type for _Float128 and __float128 should always be the same within the compiler. Whether we would continue to use the same type for long double and _Float128/__float128 remains to be seen. But in doing the change, there are several places that need to be changed as well. > If TFmode means IEEE QP float, TFmode and KFmode can be used > interchangeably. When TFmode means double-double, TFmode and IFmode can > be used interchangeably. We should never depend on TFmode being > different from both underlying modes, that way madness lies. No, this is not supported without conversions being done (even if the conversions are eventually nop conversions). GCC firmly believes that there are no modes that are equivalant and can be used interchangeably. For example, in the float128-odd.c test case we have: __float128 f128_fms (__float128 a, __float128 b, __float128 c) { return __builtin_fmaf128_round_to_odd (a, b, -c); } by default if we just use the KFmode functions (because that is how they are defined in the built-in tables) on a system where __float128 uses the long double type and uses the TFmode, and remove the code in rs6000_expand_builtin that changes the built-in (i.e. overloading by another name) right now the compiler will trap because it calls copy_to_mode_reg if the predicate fails, and the mode being copied is different from the operand. The predicate fails because the type in the insn (i.e. KFmode) is not the same as the type of the operand (i.e. TFmode), and the default predicate (i.e. register_operand, altivec_register_operand, or vsx_register_operand) checks the mode. But that can be fixed by using convert_move's instead of copy_to_mode_reg, and possibly with new predicates that support either TFmode or KFmode. However, then GCC will insert convert's going from TFmode to KFmode. Which avoids the crash, but the converts mean that the combiner won't combine the negate and __builtin_fmaf128_round_to_od and produce the single "xsmsubqpo" instruction. Instead it will generate a negate and then a "xsmaddqpo" instruction. I've played with adding new predicates that recognize either IEEE 128-bit type and a separate one that recognizes either IBM 128-bit type. This is why I proposed to have overload support so that the built-in functions will automatically use a TFmode built-in or a KFmode built-in depending on what the mode. -- Michael Meissner, IBM PO Box 98, Ayer, Massachusetts, USA, 01432 email: meiss...@linux.ibm.com