This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/54680] [SH] Unnecessary int-float-int conversion of fsca fixed point input
- From: "olegendo at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 09 Oct 2012 19:57:35 +0000
- Subject: [Bug target/54680] [SH] Unnecessary int-float-int conversion of fsca fixed point input
- Auto-submitted: auto-generated
- References: <bug-54680-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54680
--- Comment #1 from Oleg Endo <olegendo at gcc dot gnu.org> 2012-10-09 19:57:35 UTC ---
(In reply to comment #0)
>
> Another scenario that does not work however is:
>
> float test03 (int x)
> {
> return sinf ( x * 2 * pi / 65536 );
> }
>
> (Notice the missing ( ) around 2 * pi).
>
> It seems this is caused by the fact that the fsca pattern checks for a valid
> scaling constant by doing:
>
> && operands[2] == sh_fsca_int2sf ()"
>
> .. instead of looking at the values of the const_double rtx.
No, that's not the reason. The reason is that in the above case 'x * 2' is
expanded as an integer multiplication. Thus the fsca scale factor changes and
is not pi / 2**15 as expected by the fsca pattern.
This could be fixed by inspecting the fpul operand in detail, but it doesn't
seem worth doing so. Anyway user code that will use the standard sinf / cosf
functions with fixed-point inputs will be aware of SH4 fsca specifics.