Hi, The attached patch removes the fsca instruction support for DFmode on SH4A when -ffast-math is enabled.
Tested against rev 185555 with make -k check RUNTESTFLAGS="--target_board=sh-sim \{-m2/-ml,-m2/-mb,-m2a-single/-mb, -m4-single/-ml,-m4-single/-mb, -m4a-single/-ml,-m4a-single/-mb}" and no new failures. Cheers, Oleg ChangeLog: PR target/52479 * config/sh/sh-protos.h (sh_fsca_df2int): Remove. * config/sh/sh.c (sh_fsca_df2int_rtx, sh_fsca_df2int): Remove. * config/sh/sh.md (sindf2, cosdf2): Remove. testsuite/ChangeLog: PR target/52479 * gcc.target/sh/sh4a-cos.c: Remove. * gcc.target/sh/sh4a-sin.c: Remove.
Index: gcc/testsuite/gcc.target/sh/sh4a-cos.c =================================================================== --- gcc/testsuite/gcc.target/sh/sh4a-cos.c (revision 185554) +++ gcc/testsuite/gcc.target/sh/sh4a-cos.c (working copy) @@ -1,11 +0,0 @@ -/* Verify that we generate single-precision sine and cosine approximate - (fsca) in fast math mode on SH4A with FPU. */ -/* { dg-do compile { target "sh*-*-*" } } */ -/* { dg-options "-O -ffast-math" } */ -/* { dg-skip-if "" { "sh*-*-*" } { "*" } { "-m4a" "-m4a-single" "-m4a-single-only" } } */ -/* { dg-final { scan-assembler "fsca" } } */ - -#include <math.h> - -double test(double f) { return cos(f); } - Index: gcc/testsuite/gcc.target/sh/sh4a-sin.c =================================================================== --- gcc/testsuite/gcc.target/sh/sh4a-sin.c (revision 185554) +++ gcc/testsuite/gcc.target/sh/sh4a-sin.c (working copy) @@ -1,11 +0,0 @@ -/* Verify that we generate single-precision sine and cosine approximate - (fsca) in fast math mode on SH4A with FPU. */ -/* { dg-do compile { target "sh*-*-*" } } */ -/* { dg-options "-O -ffast-math" } */ -/* { dg-skip-if "" { "sh*-*-*" } { "*" } { "-m4a" "-m4a-single" "-m4a-single-only" } } */ -/* { dg-final { scan-assembler "fsca" } } */ - -#include <math.h> - -double test(double f) { return sin(f); } - Index: gcc/testsuite/gcc.target/sh/sh4a-sincos.c =================================================================== --- gcc/testsuite/gcc.target/sh/sh4a-sincos.c (revision 185554) +++ gcc/testsuite/gcc.target/sh/sh4a-sincos.c (working copy) @@ -1,12 +0,0 @@ -/* Verify that we generate a single single-precision sine and cosine - approximate (fsca) in fast math mode when a function computes both - sine and cosine. */ -/* { dg-do compile { target "sh*-*-*" } } */ -/* { dg-options "-O -ffast-math" } */ -/* { dg-skip-if "" { "sh*-*-*" } { "*" } { "-m4a" "-m4a-single" "-m4a-single-only" } } */ -/* { dg-final { scan-assembler-times "fsca" 1 } } */ - -#include <math.h> - -double test(double f) { return sin(f) + cos(f); } - Index: gcc/config/sh/sh-protos.h =================================================================== --- gcc/config/sh/sh-protos.h (revision 185554) +++ gcc/config/sh/sh-protos.h (working copy) @@ -39,7 +39,6 @@ #ifdef RTX_CODE extern rtx sh_fsca_sf2int (void); -extern rtx sh_fsca_df2int (void); extern rtx sh_fsca_int2sf (void); /* Declare functions defined in sh.c and used in templates. */ Index: gcc/config/sh/sh.c =================================================================== --- gcc/config/sh/sh.c (revision 185554) +++ gcc/config/sh/sh.c (working copy) @@ -11997,27 +11997,6 @@ return sh_fsca_sf2int_rtx; } -/* This function returns a constant rtx that represents pi / 2**15 in - DFmode. it's used to scale DFmode angles, in radians, to a - fixed-point signed 16.16-bit fraction of a full circle, i.e., 2*pi - maps to 0x10000). */ - -static GTY(()) rtx sh_fsca_df2int_rtx; - -rtx -sh_fsca_df2int (void) -{ - if (! sh_fsca_df2int_rtx) - { - REAL_VALUE_TYPE rv; - - real_from_string (&rv, "10430.378350470453"); - sh_fsca_df2int_rtx = const_double_from_real_value (rv, DFmode); - } - - return sh_fsca_df2int_rtx; -} - /* This function returns a constant rtx that represents 2**15 / pi in SFmode. it's used to scale a fixed-point signed 16.16-bit fraction of a full circle back to a SFmode value, i.e., 0x10000 maps to Index: gcc/config/sh/sh.md =================================================================== --- gcc/config/sh/sh.md (revision 185555) +++ gcc/config/sh/sh.md (working copy) @@ -10658,48 +10658,6 @@ DONE; }) -(define_expand "sindf2" - [(set (match_operand:DF 0 "fp_arith_reg_operand" "") - (unspec:DF [(match_operand:DF 1 "fp_arith_reg_operand" "")] - UNSPEC_FSINA))] - "TARGET_SH4A_FP && ! TARGET_FPU_SINGLE && flag_unsafe_math_optimizations" -{ - rtx scaled = gen_reg_rtx (DFmode); - rtx truncated = gen_reg_rtx (SImode); - rtx fsca = gen_reg_rtx (V2SFmode); - rtx scale_reg = force_reg (DFmode, sh_fsca_df2int ()); - rtx sfresult = gen_reg_rtx (SFmode); - - emit_df_insn (gen_muldf3 (scaled, operands[1], scale_reg)); - emit_df_insn (gen_fix_truncdfsi2 (truncated, scaled)); - emit_sf_insn (gen_fsca (fsca, truncated, sh_fsca_int2sf (), - get_fpscr_rtx ())); - emit_move_insn (sfresult, gen_rtx_SUBREG (SFmode, fsca, 0)); - emit_df_insn (gen_extendsfdf2 (operands[0], sfresult)); - DONE; -}) - -(define_expand "cosdf2" - [(set (match_operand:DF 0 "fp_arith_reg_operand" "") - (unspec:DF [(match_operand:DF 1 "fp_arith_reg_operand" "")] - UNSPEC_FCOSA))] - "TARGET_SH4A_FP && ! TARGET_FPU_SINGLE && flag_unsafe_math_optimizations" -{ - rtx scaled = gen_reg_rtx (DFmode); - rtx truncated = gen_reg_rtx (SImode); - rtx fsca = gen_reg_rtx (V2SFmode); - rtx scale_reg = force_reg (DFmode, sh_fsca_df2int ()); - rtx sfresult = gen_reg_rtx (SFmode); - - emit_df_insn (gen_muldf3 (scaled, operands[1], scale_reg)); - emit_df_insn (gen_fix_truncdfsi2 (truncated, scaled)); - emit_sf_insn (gen_fsca (fsca, truncated, sh_fsca_int2sf (), - get_fpscr_rtx ())); - emit_move_insn (sfresult, gen_rtx_SUBREG (SFmode, fsca, 4)); - emit_df_insn (gen_extendsfdf2 (operands[0], sfresult)); - DONE; -}) - (define_expand "abssf2" [(set (match_operand:SF 0 "fp_arith_reg_operand" "") (abs:SF (match_operand:SF 1 "fp_arith_reg_operand" "")))]