diff mbox

Fix math transformation on targets without c99 math functions

Message ID DF2450C6-D371-4A2C-B679-9961E2021431@bell.net
State New
Headers show

Commit Message

John David Anglin Dec. 28, 2015, 8:21 p.m. UTC
The attach change fixes PR middle-end/68743 on hppa*-*-hpux*.  In compiling 
c99_functions.c in libgfortran, floor ((double)x) was transformed to floorf(x) but
floorf is not available on hppa*-*-hpux*.  The change simply adds a libc_has_function
check to prevent the transformation.

Tested on hppa2.0w-hp-hpux11.11 and hppa64-hp-hpux11.11.

Okay for trunk?

Dave
--
John David Anglin	dave.anglin@bell.net
2015-12-28  John David Anglin  <danglin@gcc.gnu.org>

	PR middle-end/68743
	* match.pd: Require target has function_c99_math_complex before
	doing truncl(extend(x)) and trunc(extend(x)) -> extend(truncf(x)), etc.

Comments

Joseph Myers Dec. 30, 2015, 11:46 p.m. UTC | #1
On Mon, 28 Dec 2015, John David Anglin wrote:

> The attach change fixes PR middle-end/68743 on hppa*-*-hpux*.  In compiling 
> c99_functions.c in libgfortran, floor ((double)x) was transformed to floorf(x) but
> floorf is not available on hppa*-*-hpux*.  The change simply adds a libc_has_function
> check to prevent the transformation.

These are real functions, not complex.  I think you want to use 
function_c99_misc, not function_c99_complex.
John David Anglin Dec. 31, 2015, 5:52 p.m. UTC | #2
On 2015-12-30, at 6:46 PM, Joseph Myers wrote:

> On Mon, 28 Dec 2015, John David Anglin wrote:
> 
>> The attach change fixes PR middle-end/68743 on hppa*-*-hpux*.  In compiling 
>> c99_functions.c in libgfortran, floor ((double)x) was transformed to floorf(x) but
>> floorf is not available on hppa*-*-hpux*.  The change simply adds a libc_has_function
>> check to prevent the transformation.
> 
> These are real functions, not complex.  I think you want to use 
> function_c99_misc, not function_c99_complex.


The composition of the classes isn't documented, so I wasn't sure which functions where in
each class.  Thought function_c99_math_complex might have been math and complex.

In any case, we have no_c99_libc_has_function on hpux and everything on linux.  So, I
don't think testing with function_c99_misc on hppa will show any difference.

Okay with function_c99_misc?

Dave
--
John David Anglin	dave.anglin@bell.net
Jakub Jelinek Jan. 9, 2016, 4:48 p.m. UTC | #3
On Thu, Dec 31, 2015 at 12:52:21PM -0500, John David Anglin wrote:
> On 2015-12-30, at 6:46 PM, Joseph Myers wrote:
> 
> > On Mon, 28 Dec 2015, John David Anglin wrote:
> > 
> >> The attach change fixes PR middle-end/68743 on hppa*-*-hpux*.  In compiling 
> >> c99_functions.c in libgfortran, floor ((double)x) was transformed to floorf(x) but
> >> floorf is not available on hppa*-*-hpux*.  The change simply adds a libc_has_function
> >> check to prevent the transformation.
> > 
> > These are real functions, not complex.  I think you want to use 
> > function_c99_misc, not function_c99_complex.
> 
> 
> The composition of the classes isn't documented, so I wasn't sure which functions where in
> each class.  Thought function_c99_math_complex might have been math and complex.
> 
> In any case, we have no_c99_libc_has_function on hpux and everything on linux.  So, I
> don't think testing with function_c99_misc on hppa will show any difference.
> 
> Okay with function_c99_misc?

Ok (but please make sure to adjust ChangeLog too).

	Jakub
Christophe Lyon Jan. 11, 2016, 1:16 p.m. UTC | #4
On 9 January 2016 at 17:48, Jakub Jelinek <jakub@redhat.com> wrote:
> On Thu, Dec 31, 2015 at 12:52:21PM -0500, John David Anglin wrote:
>> On 2015-12-30, at 6:46 PM, Joseph Myers wrote:
>>
>> > On Mon, 28 Dec 2015, John David Anglin wrote:
>> >
>> >> The attach change fixes PR middle-end/68743 on hppa*-*-hpux*.  In compiling
>> >> c99_functions.c in libgfortran, floor ((double)x) was transformed to floorf(x) but
>> >> floorf is not available on hppa*-*-hpux*.  The change simply adds a libc_has_function
>> >> check to prevent the transformation.
>> >
>> > These are real functions, not complex.  I think you want to use
>> > function_c99_misc, not function_c99_complex.
>>
>>
>> The composition of the classes isn't documented, so I wasn't sure which functions where in
>> each class.  Thought function_c99_math_complex might have been math and complex.
>>
>> In any case, we have no_c99_libc_has_function on hpux and everything on linux.  So, I
>> don't think testing with function_c99_misc on hppa will show any difference.
>>
>> Okay with function_c99_misc?
>
> Ok (but please make sure to adjust ChangeLog too).
>

This patch made gcc.dg/torture/builtin-integral-1.c FAIL on
bare metal targets (e.g. arm-non-eabi, aarch64-none-elf,
using Newlib).
The logs show link errors:
/ccOMzAOC.o: In function `test':
builtin-integral-1.c:(.text+0x3c): undefined reference to `link_failure'
collect2: error: ld returned 1 exit status

Christophe


>         Jakub
Jakub Jelinek Jan. 11, 2016, 1:24 p.m. UTC | #5
On Mon, Jan 11, 2016 at 02:16:31PM +0100, Christophe Lyon wrote:
> >> In any case, we have no_c99_libc_has_function on hpux and everything on linux.  So, I
> >> don't think testing with function_c99_misc on hppa will show any difference.
> >>
> >> Okay with function_c99_misc?
> >
> > Ok (but please make sure to adjust ChangeLog too).
> >
> 
> This patch made gcc.dg/torture/builtin-integral-1.c FAIL on
> bare metal targets (e.g. arm-non-eabi, aarch64-none-elf,
> using Newlib).
> The logs show link errors:
> /ccOMzAOC.o: In function `test':
> builtin-integral-1.c:(.text+0x3c): undefined reference to `link_failure'
> collect2: error: ld returned 1 exit status

I'd say you want to either split that test into the double and float+long
double functions and limit the latter only to c99_runtime targets
(and add add_options_for_c99_runtime), or just guard the whole test
with c99_runtime and add_options_for_c99_runtime.

	Jakub
diff mbox

Patch

Index: match.pd
===================================================================
--- match.pd	(revision 231669)
+++ match.pd	(working copy)
@@ -2784,7 +2784,8 @@ 
 	  BUILT_IN_RINTF BUILT_IN_RINTF)
  /* truncl(extend(x)) and trunc(extend(x)) -> extend(truncf(x)), etc.,
     if x is a float.  */
- (if (optimize && canonicalize_math_p ())
+ (if (optimize && canonicalize_math_p ()
+      && targetm.libc_has_function (function_c99_math_complex))
   (simplify
    (froms (convert float_value_p@0))
    (convert (tos @0)))))