On Fri, Nov 17, 2017 at 08:06:09AM -0600, Segher Boessenkool wrote: > Hi! > > On Fri, Nov 17, 2017 at 12:04:45AM -0500, Michael Meissner wrote: > > This patch is an enhancement of a previous page that never got approved. > > https://gcc.gnu.org/ml/gcc-patches/2017-10/threads.html#02124 > > > > In the original patch, I added support to the machine independent > > infrastructure to support the rounding built-in functions for _Float and > > _FloatX types (i.e. roundf128, ceilf128, etc.). I also added PowerPC ISA > > 3.0 support to generate these built-in functions. > > > > In addition to the previous changes, this patch now adds more optimizations for > > _Float and _FloatX types in match.pd. > > > +(define_insn "btrunc2" > > + [(set (match_operand:IEEE128 0 "altivec_register_operand" "=v") > > + (unspec:IEEE128 > > + [(match_operand:IEEE128 1 "altivec_register_operand" "v")] > > + UNSPEC_FRIZ))] > > + "TARGET_FLOAT128_HW && FLOAT128_IEEE_P (mode)" > > + "xsrqpi 1,%0,%1,0" > > + [(set_attr "type" "vecfloat") > > + (set_attr "size" "128")]) > > Is this one correct? Truncate is RMC=1, not RMC=0, I think? > > The rest of the rs6000 part looks fine. Thanks! Here is the fixed patch. It fixes the btrunc2 insn to use the correct XSRPQI variant for truncf128. I added the float128-hw11.c test as a runtime test to make sure round, trunc, ceil, and floor return the correct values. The machine independent portions are the same. Assuming the machine independent versions are approved, can I check in the PowerPC bits? [gcc] 2017-11-17 Michael Meissner * builtins.def: (_Float and _FloatX BUILT_IN_CEIL): Add _Float and _FloatX variants for rounding built-in functions. (_Float and _FloatX BUILT_IN_FLOOR): Likewise. (_Float and _FloatX BUILT_IN_NEARBYINT): Likewise. (_Float and _FloatX BUILT_IN_RINT): Likewise. (_Float and _FloatX BUILT_IN_ROUND): Likewise. (_Float and _FloatX BUILT_IN_TRUNC): Likewise. * builtins.c (mathfn_built_in_2): Likewise. * internal-fn.def (CEIL): Likewise. (FLOOR): Likewise. (NEARBYINT): Likewise. (RINT): Likewise. (ROUND): Likewise. (TRUNC): Likewise. * convert.c (convert_to_integer_1): Likewise. * fold-const.c (tree_call_nonnegative_warnv_p): Likewise. (integer_valued_real_call_p): Likewise. * fold-const-call.c (fold_const_call_ss): Likewise. * gencfn-macros.c (print_case_cfn): Change CFN and operator printers to take a const char * suffix instead of a bool. (print_define_operator_list): Likewise. (fltall_suffixes): New list of suffixes, that include the traditional suffixes as well as all of the _Float and _FloatX suffixes. (main): For _Float and _FloatX functions, emit both _FN and _ALL variants. The _FN variant only has the _Float and _FloatX case names or operators. The _ALL variant has both the traditional and the _Float/_FloatX case names or operators. * match.pd (COPYSIGN optimizations): Provide optimizations for _Float and _FloatX types where possible. (MIN/MAX optimizations): Likewise. (sqrt optimizations): Likewise. (rounding optimizations): Likewise. * config/rs6000/rs6000.md (floor2): Add support for IEEE 128-bit round to integer instructions. (ceil2): Likewise. (btrunc2): Likewise. (round2): Likewise. [gcc/c] 2017-11-17 Michael Meissner * c-decl.c (header_for_builtin_fn): Add integer rounding _Float and _FloatX built-in functions. [gcc/testsuite] 2017-11-17 Michael Meissner * gcc.target/powerpc/float128-hw2.c: Add tests for ceilf128, floorf128, truncf128, and roundf128. * gcc.target/powerpc/float128-hw5.c: New tests for _Float128 optimizations added in match.pd. * gcc.target/powerpc/float128-hw6.c: Likewise. * gcc.target/powerpc/float128-hw7.c: Likewise. * gcc.target/powerpc/float128-hw8.c: Likewise. * gcc.target/powerpc/float128-hw9.c: Likewise. * gcc.target/powerpc/float128-hw10.c: Likewise. * gcc.target/powerpc/float128-hw11.c: Likewise. -- Michael Meissner, IBM IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA email: meissner@linux.vnet.ibm.com, phone: +1 (978) 899-4797