bagel99 / llvm-my66000

This is a fork of the LLVM project. The code in branch my66000 supports Mitch Alsup's MY66000. The code in branch mcore supports the Motorola MCore.
http://llvm.org
Other
2 stars 2 forks source link

Make -fno-math-errno the default #42

Open tkoenig1 opened 1 year ago

tkoenig1 commented 1 year ago

Setting errno on math functions makes little sense for the best architectures, and even less for my66000:

$ cat mycos.c 
#include <math.h>

double mycos(double x)
{
  return cos(x);
}
$ clang --target=my66000 -c -emit-llvm -O2 mycos.c 
$ llc -O2 -march=my66000 mycos.bc
$ cat mycos.s 
        .text
        .file   "mycos.c"
        .globl  mycos                           ; -- Begin function mycos
        .type   mycos,@function
mycos:                                  ; @mycos
; %bb.0:                                ; %entry
        br      cos
.Lfunc_end0:
        .size   mycos, .Lfunc_end0-mycos
                                        ; -- End function
        .ident  "clang version 15.0.0 (https://github.com/bagel99/llvm-my66000.git af7ee91ac91db0ac489c686eb35daf15ceb1f32f)"
        .section        ".note.GNU-stack","",@progbits
$ clang -fno-math-errno --target=my66000 -c -emit-llvm -O2 mycos.c 
$ llc -O2 -march=my66000 mycos.bc
$ cat mycos.s 
        .text
        .file   "mycos.c"
        .globl  mycos                           ; -- Begin function mycos
        .type   mycos,@function
mycos:                                  ; @mycos
; %bb.0:                                ; %entry
        fcos    r1,r1
        ret
.Lfunc_end0:
        .size   mycos, .Lfunc_end0-mycos
                                        ; -- End function
        .ident  "clang version 15.0.0 (https://github.com/bagel99/llvm-my66000.git af7ee91ac91db0ac489c686eb35daf15ceb1f32f)"
        .section        ".note.GNU-stack","",@progbits

which shows that, without that flag, a library function is invoked instead of the transcendental instruction.