mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Damian McGuckin <damianm@esi.com.au>
To: musl@lists.openwall.com
Subject: Re: FE Exception triggered by comparison
Date: Thu, 28 Feb 2019 03:09:54 +1100 (AEDT)	[thread overview]
Message-ID: <alpine.LRH.2.02.1902280305570.11194@key0.esi.com.au> (raw)
In-Reply-To: <alpine.LNX.2.20.13.1902271852451.30425@monopod.intra.ispras.ru>


Thanks for the feedback.

On Wed, 27 Feb 2019, Alexander Monakov wrote:

> On Thu, 28 Feb 2019, Damian McGuckin wrote:
>
>> I tried the code below, I was just shocked.
>>
>> 	#include	<math.h>
>> 	#include	<stdio.h>
>>
>> 	main()
>> 	{
>> 		double x = 5.0;
>>
>> 		x -= x, x /= x;
>> 		printf("what %s\n", isnan(x) ? "yes" : "no!");
>> 		return(0);
>> 	}
>>
>> Looking at the assembler, there is a subroutine call to __isnan. Awful!
>
> Hm, no, for x86 with GCC you should not see that: the compiler knows how 
> to expand isnan efficiently.  Are you perhaps on OS X and the 'gcc' 
> command actually invokes Clang/LLVM?

No.

> If not, can you show output of 'gcc -v', command-line flags you used, 
> and the assembly you're seeing?

 	gcc -O3 -S -msse4.2 -mfma mynan.c

Here is the assembler:

 	.file	"mynan.c"
 	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
 	.string	"yes"
.LC1:
 	.string	"no!"
.LC3:
 	.string	"what %s\n"
 	.section	.text.startup,"ax",@progbits
 	.p2align 4,,15
 	.globl	main
 	.type	main, @function
main:
.LFB14:
 	.cfi_startproc
 	vxorpd	%xmm0, %xmm0, %xmm0
 	subq	$8, %rsp
 	.cfi_def_cfa_offset 16
 	vdivsd	%xmm0, %xmm0, %xmm0
 	call	__isnan
 	movl	$.LC0, %esi
 	testl	%eax, %eax
 	movl	$.LC1, %eax
 	cmove	%rax, %rsi
 	movl	$.LC3, %edi
 	xorl	%eax, %eax
 	call	printf
 	xorl	%eax, %eax
 	addq	$8, %rsp
 	.cfi_def_cfa_offset 8
 	ret
 	.cfi_endproc
.LFE14:
 	.size	main, .-main
 	.ident	"GCC: (GNU) 4.8.5 20150623 (Red Hat 4.8.5-36)"
 	.section	.note.GNU-stack,"",@progbits

Regards - Damian

Pacific Engineering Systems International, 277-279 Broadway, Glebe NSW 2037
Ph:+61-2-8571-0847 .. Fx:+61-2-9692-9623 | unsolicited email not wanted here
Views & opinions here are mine and not those of any past or present employer


  reply	other threads:[~2019-02-27 16:09 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-24 13:28 Damian McGuckin
2019-02-24 17:12 ` Markus Wichmann
2019-02-24 19:25 ` Szabolcs Nagy
2019-02-24 20:04   ` Jens Gustedt
2019-02-24 21:50     ` Damian McGuckin
2019-02-25  5:21       ` Damian McGuckin
2019-02-25 15:51       ` Markus Wichmann
2019-02-26  3:55         ` Damian McGuckin
2019-02-27 14:14           ` Alexander Monakov
2019-02-27 15:38             ` Damian McGuckin
2019-02-27 16:00               ` Alexander Monakov
2019-02-27 16:09                 ` Damian McGuckin [this message]
2019-02-27 16:14                   ` Markus Wichmann
2019-02-27 16:20                     ` Damian McGuckin
2019-02-28  1:07                     ` Damian McGuckin
2019-02-28  1:27                       ` Rich Felker
2019-02-28  2:28                         ` Damian McGuckin
2019-02-27 16:32                   ` Alexander Monakov
2019-02-27 16:42                     ` Rich Felker
2019-02-27 17:08                       ` Szabolcs Nagy
2019-02-27 17:14                       ` Alexander Monakov
2019-02-27 17:26                         ` Rich Felker
2019-02-27 19:36                           ` Szabolcs Nagy
2019-02-27 19:48                           ` Alexander Monakov
2019-02-27 20:16                             ` Szabolcs Nagy
2019-02-27 20:35                               ` Rich Felker
2019-02-27 21:03                                 ` Szabolcs Nagy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LRH.2.02.1902280305570.11194@key0.esi.com.au \
    --to=damianm@esi.com.au \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).