Re: [PATCH], Add power9 support to GCC, patch #6 (IEEE 128-bit hardware support)
On Sun, Nov 8, 2015 at 7:44 PM, Michael Meissner wrote: > This patch adds support for the IEEE 128-bit hardware instructions that are > being added to the PowerPC ISA 3.0 (power9). With this patch, users on power7 > and power8 will use the software emulation functions that are committed, but > still need some enhancment. On ISA 3.0/power9, they would be able to use the > direct instructions. > > I have built this patch with a bootstrap build on a power8 little endian > system. There were no regressions in the test suite. Is this patch ok to > install in the trunk? > > [gcc] > 2015-11-08 Michael Meissner > > * config/rs6000/rs6000-protos.h (convert_float128_to_int): Add > declaration. > (convert_int_to_float128): Likewise. > (rs6000_generate_compare): Add support for ISA 3.0 (power9) > hardware support for IEEE 128-bit floating point. > (rs6000_expand_float128_convert): Likewise. > (convert_float128_to_int): Likewise. > (convert_int_to_float128): Likewise. > > * config/rs6000/rs6000.md (UNSPEC_ROUND_TO_ODD): New unspecs for > ISA 3.0 hardware IEEE 128-bit floating point. > (UNSPEC_IEEE128_MOVE): Likewise. > (UNSPEC_IEEE128_CONVERT): Likewise. > (FMA_F): Add support for IEEE 128-bit floating point hardware > support. > (Ff): Add support for DImode. > (Fv): Likewise. > (any_fix code iterator): New and updated iterators for IEEE > 128-bit floating point hardware support. > (any_float code iterator): Likewise. > (s code attribute): Likewise. > (su code attribute): Likewise. > (az code attribute): Likewise. > (neg2, FLOAT128 iterator): Add support for IEEE 128-bit > floating point hardware support. > (abs2, FLOAT128 iterator): Likewise. > (add3, IEEE128 iterator): New insns for IEEE 128-bit > floating point hardware. > (sub3, IEEE128 iterator): Likewise. > (mul3, IEEE128 iterator): Likewise. > (div3, IEEE128 iterator): Likewise. > (copysign3, IEEE128 iterator): Likewise. > (sqrt2, IEEE128 iterator): Likewise. > (neg2, IEEE128 iterator): Likewise. > (abs2, IEEE128 iterator): Likewise. > (nabs2, IEEE128 iterator): Likewise. > (fma4_hw, IEEE128 iterator): Likewise. > (fms4_hw, IEEE128 iterator): Likewise. > (nfma4_hw, IEEE128 iterator): Likewise. > (nfms4_hw, IEEE128 iterator): Likewise. > (extend2_hw): Likewise. > (truncdf2_hw, IEEE128 iterator): Likewise. > (truncsf2_hw, IEEE128 iterator): Likewise. > (fix_fixuns code attribute): Likewise. > (float_floatuns code attribute): Likewise. > (_si2_hw): Likewise. > (_di2_hw): Likewise. > (_si2_hw): Likewise. > (_di2_hw): Likewise. > (xscvqpwz_): Likewise. > (xscvqpdz_): Likewise. > (xscvdqp_ (ieee128_mfvsrd): Likewise. > (ieee128_mfvsrwz): Likewise. > (ieee128_mtvsrw): Likewise. > (ieee128_mtvsrd): Likewise. > (truncdf2_odd): Likewise. > (cmp_h): Likewise. > > [gcc/testsuite] > 2015-11-08 Michael Meissner > > * gcc.target/powerpc/float128-hw.c: New test for IEEE 128-bit > hardware floating point support. Please change the attribute to "uns" as suggested by Segher. > +(define_code_attr fix_fixuns [(fix "fix") (unsigned_fix "fixuns")]) > +(define_code_attr float_floatuns [(float "float") (unsigned_float "floatuns")]) You could instead do an "uns" attribute so you would write fix etc. Okay with that change. We need to think more about ieee128_mtvsw pattern. Thanks, David
Re: [PATCH], Add power9 support to GCC, patch #6 (IEEE 128-bit hardware support)
On Tue, Nov 10, 2015 at 12:41:07AM +, Joseph Myers wrote: > I don't see any conversions between KFmode and TImode (in either > direction, signed or unsigned) here - I suppose there are no instructions > for that? No in power9 there is no instruction that converts 128-bit integer to IEEE 128-bit floating point or vice versa. > If so, I would guess (without having tested it) that it is more efficient > to use the libgcc2 implementations of those functions (whether copied, or > with some logic to build selected libgcc2.c functions for KFmode), which > implement them using a few hardware operations on DImode [note that where > libgcc2.c has e.g. __floatditf, that gets mapped to __floattitf for 64-bit > systems], than to use the soft-fp implementations doing everything with > integer arithmetic. (There are IEEE exceptions issues with the libgcc2.c > conversions from double-word integers to floating-point - see bug 59412 - > but since that's a preexisting issue for all architectures using this > code, it's clearly not your problem to fix.) > > Ideally, I'd think that for optimal efficiency if objects built for power8 > are linked with libgcc built for power9, or if an executable using shared > libgcc that was built for power8 gets run with shared libgcc for power9, > you'd want power9 libgcc to contain t-hardfp versions of all the functions > that can be expanded inline for power9, and libgcc2 versions of those > (such as TImode comparisons) that aren't expanded inline, but not to > contain soft-fp versions of any of those KFmode functions. Cf. how > config.host ensures various 32-bit powerpc variants use the right mixture > of hardfp and soft-fp functions. It's a bit fiddly to make sure you get > the preferred implementation of every function and that the ABI doesn't > change depending on the configured processor, but not that hard. Yep, that is my thinking. > Since none of the libgcc pieces for KFmode support are yet in, and the > proposed changes are optimizations rather than a matter of correctness, > none of the above should directly affect this patch in any way - it simply > indicates desirable followup once both the libgcc soft-fp KFmode support, > and this patch, are in. -- Michael Meissner, IBM IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA email: meiss...@linux.vnet.ibm.com, phone: +1 (978) 899-4797
Re: [PATCH], Add power9 support to GCC, patch #6 (IEEE 128-bit hardware support)
I don't see any conversions between KFmode and TImode (in either direction, signed or unsigned) here - I suppose there are no instructions for that? If so, I would guess (without having tested it) that it is more efficient to use the libgcc2 implementations of those functions (whether copied, or with some logic to build selected libgcc2.c functions for KFmode), which implement them using a few hardware operations on DImode [note that where libgcc2.c has e.g. __floatditf, that gets mapped to __floattitf for 64-bit systems], than to use the soft-fp implementations doing everything with integer arithmetic. (There are IEEE exceptions issues with the libgcc2.c conversions from double-word integers to floating-point - see bug 59412 - but since that's a preexisting issue for all architectures using this code, it's clearly not your problem to fix.) Ideally, I'd think that for optimal efficiency if objects built for power8 are linked with libgcc built for power9, or if an executable using shared libgcc that was built for power8 gets run with shared libgcc for power9, you'd want power9 libgcc to contain t-hardfp versions of all the functions that can be expanded inline for power9, and libgcc2 versions of those (such as TImode comparisons) that aren't expanded inline, but not to contain soft-fp versions of any of those KFmode functions. Cf. how config.host ensures various 32-bit powerpc variants use the right mixture of hardfp and soft-fp functions. It's a bit fiddly to make sure you get the preferred implementation of every function and that the ABI doesn't change depending on the configured processor, but not that hard. Since none of the libgcc pieces for KFmode support are yet in, and the proposed changes are optimizations rather than a matter of correctness, none of the above should directly affect this patch in any way - it simply indicates desirable followup once both the libgcc soft-fp KFmode support, and this patch, are in. -- Joseph S. Myers jos...@codesourcery.com
Re: [PATCH], Add power9 support to GCC, patch #6 (IEEE 128-bit hardware support)
On Sun, Nov 08, 2015 at 07:44:52PM -0500, Michael Meissner wrote: > +/* Split a conversion from __float128 to an integer type into separate insns. > + OPERANDS points to the destination, source, and V2DI temporary > + register. CODE is either FIX or UNSIGNED_FIX. */ dot space space > +;; ISA 2.08 IEEE 128-bit floating point support. 3.0 > +(define_code_attr fix_fixuns [(fix "fix") (unsigned_fix "fixuns")]) > +(define_code_attr float_floatuns [(float "float") (unsigned_float > "floatuns")]) You could instead do an "uns" attribute so you would write fix etc. > +;; 0 says do sign-extension, 1 says zero-extension > +(define_insn "*ieee128_mtvsrw" > + [(set (match_operand:V2DI 0 "altivec_register_operand" "=v,v,v,v") > + (unspec:V2DI [(match_operand:SI 1 "nonimmediate_operand" "r,Z,r,Z") > + (match_operand:SI 2 "const_0_to_1_operand" "O,O,n,n")] > + UNSPEC_IEEE128_MOVE))] > + "TARGET_FLOAT128_HW" > + "@ > + mtvsrwa %x0,%1 > + lxsiwax %x0,%y1 > + mtvsrwz %x0,%1 > + lxsiwzx %x0,%y1" > + [(set_attr "type" "mffgpr,fpload,mffgpr,fpload")]) Tricky, is there no cleaner way to do this? Segher
Re: [PATCH], Add power9 support to GCC, patch #6 (IEEE 128-bit hardware support)
This patch adds support for the IEEE 128-bit hardware instructions that are being added to the PowerPC ISA 3.0 (power9). With this patch, users on power7 and power8 will use the software emulation functions that are committed, but still need some enhancment. On ISA 3.0/power9, they would be able to use the direct instructions. I have built this patch with a bootstrap build on a power8 little endian system. There were no regressions in the test suite. Is this patch ok to install in the trunk? [gcc] 2015-11-08 Michael Meissner * config/rs6000/rs6000-protos.h (convert_float128_to_int): Add declaration. (convert_int_to_float128): Likewise. (rs6000_generate_compare): Add support for ISA 3.0 (power9) hardware support for IEEE 128-bit floating point. (rs6000_expand_float128_convert): Likewise. (convert_float128_to_int): Likewise. (convert_int_to_float128): Likewise. * config/rs6000/rs6000.md (UNSPEC_ROUND_TO_ODD): New unspecs for ISA 3.0 hardware IEEE 128-bit floating point. (UNSPEC_IEEE128_MOVE): Likewise. (UNSPEC_IEEE128_CONVERT): Likewise. (FMA_F): Add support for IEEE 128-bit floating point hardware support. (Ff): Add support for DImode. (Fv): Likewise. (any_fix code iterator): New and updated iterators for IEEE 128-bit floating point hardware support. (any_float code iterator): Likewise. (s code attribute): Likewise. (su code attribute): Likewise. (az code attribute): Likewise. (neg2, FLOAT128 iterator): Add support for IEEE 128-bit floating point hardware support. (abs2, FLOAT128 iterator): Likewise. (add3, IEEE128 iterator): New insns for IEEE 128-bit floating point hardware. (sub3, IEEE128 iterator): Likewise. (mul3, IEEE128 iterator): Likewise. (div3, IEEE128 iterator): Likewise. (copysign3, IEEE128 iterator): Likewise. (sqrt2, IEEE128 iterator): Likewise. (neg2, IEEE128 iterator): Likewise. (abs2, IEEE128 iterator): Likewise. (nabs2, IEEE128 iterator): Likewise. (fma4_hw, IEEE128 iterator): Likewise. (fms4_hw, IEEE128 iterator): Likewise. (nfma4_hw, IEEE128 iterator): Likewise. (nfms4_hw, IEEE128 iterator): Likewise. (extend2_hw): Likewise. (truncdf2_hw, IEEE128 iterator): Likewise. (truncsf2_hw, IEEE128 iterator): Likewise. (fix_fixuns code attribute): Likewise. (float_floatuns code attribute): Likewise. (_si2_hw): Likewise. (_di2_hw): Likewise. (_si2_hw): Likewise. (_di2_hw): Likewise. (xscvqpwz_): Likewise. (xscvqpdz_): Likewise. (xscvdqp_df2_odd): Likewise. (cmp_h): Likewise. [gcc/testsuite] 2015-11-08 Michael Meissner * gcc.target/powerpc/float128-hw.c: New test for IEEE 128-bit hardware floating point support. -- Michael Meissner, IBM IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA email: meiss...@linux.vnet.ibm.com, phone: +1 (978) 899-4797 Index: gcc/config/rs6000/rs6000-protos.h === --- gcc/config/rs6000/rs6000-protos.h (revision 229976) +++ gcc/config/rs6000/rs6000-protos.h (working copy) @@ -55,6 +55,8 @@ extern const char *rs6000_output_move_12 extern bool rs6000_move_128bit_ok_p (rtx []); extern bool rs6000_split_128bit_ok_p (rtx []); extern void rs6000_expand_float128_convert (rtx, rtx, bool); +extern void convert_float128_to_int (rtx *, enum rtx_code); +extern void convert_int_to_float128 (rtx *, enum rtx_code); extern void rs6000_expand_vector_init (rtx, rtx); extern void paired_expand_vector_init (rtx, rtx); extern void rs6000_expand_vector_set (rtx, rtx, int); Index: gcc/config/rs6000/rs6000.c === --- gcc/config/rs6000/rs6000.c (revision 229976) +++ gcc/config/rs6000/rs6000.c (working copy) @@ -20504,11 +20504,12 @@ rs6000_generate_compare (rtx cmp, machin emit_insn (cmp); } - /* IEEE 128-bit support in VSX registers. The comparison functions - (__cmpokf2 and __cmpukf2) returns 0..15 that is laid out the same way as - the PowerPC CR register would for a normal floating point comparison from - the fcmpo and fcmpu instructions. */ - else if (FLOAT128_IEEE_P (mode)) + /* IEEE 128-bit support in VSX registers. If we do not have IEEE 128-bit + hardware, the comparison functions (__cmpokf2 and __cmpukf2) returns 0..15 + that is laid out the same way as the PowerPC CR register would for a + normal floating point comparison from the fcmpo and fcmpu + instructions. */ + else if (!TARGET_FLOAT128_HW && FLOAT128_IEEE_P (mode)) { rtx and_reg = gen_reg_rtx (SImode); rtx dest = gen_reg_rtx (SImode); @@ -20647,7 +20648,7 @@ rs6000_generate