This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

several libm functions instantiations - SPARC


Hi,

When analyzing some disassembled code I observed an issue which seems
like a bug to me. I'll try to properly describe it below. However I'm
wondering if this comes from something that went wrong while building
the cross-compiler, from the linker or from some option I'm not using
rightly.

----------------------------------------- ISSUE
When compiling codes that use the libm (I didn't get to reproduce the
test with other libs, I didn't try that much either), many functions
appear quite a few times in the disassembled file. I wrote this
minimalist test case to reproduce the issue with ISNAN but this extends
to several functions in benchmarks like Paranoia.

----------------------------------------- GCC
This test has been done with GCC 4.5.1 and mainline built for SPARCV8.

/opt/sparc-elf-4.5.1/bin/sparc-elf-gcc test.c -Os -flto -fwhole-program
-finline -ffunction-sections -fdata-sections -e main -Wl,--gc-sections
-nostdlib -lm -lgcc

----------------------------------------- C code
#include <math.h>
int main(){
  int i, a;
  for(i=-10;i<=10;i++){a+=isnan(i);}
  return a;
}

----------------------------------------- Bytecode
40000000 <main>:
4000003c <isnan>:      <------------------------------------ First
instantiation
4000003c:    9d e3 bf a0     save  %sp, -96, %sp
40000040:    f0 27 a0 44     st  %i0, [ %fp + 0x44 ]
40000044:    c2 07 a0 44     ld  [ %fp + 0x44 ], %g1
40000048:    c2 00 40 00     ld  [ %g1 ], %g1
4000004c:    82 18 60 00     xor  %g1, 0, %g1
40000050:    80 a0 00 01     cmp  %g0, %g1
40000054:    82 60 3f ff     subx  %g0, -1, %g1
40000058:    80 a0 60 00     cmp  %g1, 0
4000005c:    12 80 00 0a     bne  40000084 <isnan+0x48>
40000060:    01 00 00 00     nop
40000064:    c2 07 a0 44     ld  [ %fp + 0x44 ], %g1
40000068:    c2 00 40 00     ld  [ %g1 ], %g1
4000006c:    82 18 60 01     xor  %g1, 1, %g1
40000070:    80 a0 00 01     cmp  %g0, %g1
40000074:    82 60 3f ff     subx  %g0, -1, %g1
40000078:    80 a0 60 00     cmp  %g1, 0
4000007c:    02 80 00 05     be  40000090 <isnan+0x54>
40000080:    01 00 00 00     nop
40000084:    82 10 20 01     mov  1, %g1    ! 1 <main-0x3fffffff>
40000088:    10 80 00 03     b  40000094 <isnan+0x58>
4000008c:    01 00 00 00     nop
40000090:    82 10 20 00     clr  %g1    ! 0 <main-0x40000000>
40000094:    b0 10 00 01     mov  %g1, %i0
40000098:    81 e8 00 00     restore
4000009c:    81 c3 e0 08     retl
400000a0:    01 00 00 00     nop

400000a4 <__unorddf2>:
40000150 <clzusi>:
40000178 <__floatsidf>:
400002d8 <__clzsi2>:

40000398 <isnan>:      <------------------------------------ Second
instantiation
40000398:    9d e3 bf a0     save  %sp, -96, %sp
4000039c:    f0 27 a0 44     st  %i0, [ %fp + 0x44 ]
400003a0:    c2 07 a0 44     ld  [ %fp + 0x44 ], %g1
400003a4:    c2 00 40 00     ld  [ %g1 ], %g1
400003a8:    82 18 60 00     xor  %g1, 0, %g1
400003ac:    80 a0 00 01     cmp  %g0, %g1
400003b0:    82 60 3f ff     subx  %g0, -1, %g1
400003b4:    80 a0 60 00     cmp  %g1, 0
400003b8:    12 80 00 0a     bne  400003e0 <isnan+0x48>
400003bc:    01 00 00 00     nop
400003c0:    c2 07 a0 44     ld  [ %fp + 0x44 ], %g1
400003c4:    c2 00 40 00     ld  [ %g1 ], %g1
400003c8:    82 18 60 01     xor  %g1, 1, %g1
400003cc:    80 a0 00 01     cmp  %g0, %g1
400003d0:    82 60 3f ff     subx  %g0, -1, %g1
400003d4:    80 a0 60 00     cmp  %g1, 0
400003d8:    02 80 00 05     be  400003ec <isnan+0x54>
400003dc:    01 00 00 00     nop
400003e0:    82 10 20 01     mov  1, %g1    ! 1 <main-0x3fffffff>
400003e4:    10 80 00 03     b  400003f0 <isnan+0x58>
400003e8:    01 00 00 00     nop
400003ec:    82 10 20 00     clr  %g1    ! 0 <main-0x40000000>
400003f0:    b0 10 00 01     mov  %g1, %i0
400003f4:    81 e8 00 00     restore
400003f8:    81 c3 e0 08     retl
400003fc:    01 00 00 00     nop

40000400 <isinf>:
4000042c <iszero>:
40000458 <__pack_d>:
40000960 <__unpack_d>:
40000bd0 <___CTOR_LIST__>:
40000bd8 <___CTOR_END__>:
40000be0 <___DTOR_END__>:
40000be8 <__clz_tab>:



I'll appreciate any feedback you provide,

Thanks in advance,



Jorge


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]