Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sin and cos of std::simd come out wrong with clang++ #20

Open
kfjahnke opened this issue Dec 14, 2020 · 1 comment
Open

sin and cos of std::simd come out wrong with clang++ #20

kfjahnke opened this issue Dec 14, 2020 · 1 comment

Comments

@kfjahnke
Copy link

version / revision | Operating System | Compiler & Version | Compiler Flags | CPU
repo as per Dec 14 2020 | ubuntu 20.04 | clang++ 10.0.0 | --std=c++17 | Haswell core i5

Here's a strange one, affecting only clang++, both for single and double precision. Other trigonometric funcions I tested come out right.

Testcase

#include <iostream>
#include <experimental/simd>

typedef std::experimental::simd
          < float ,
            std::experimental::simd_abi::fixed_size < 4 >
          > f4_t ;

int main ( int argc , char * argv[] )
{
  f4_t f4 ( .5f ) ;

  f4_t r4 = sin ( f4 ) ;
  std::cout << "sin " << f4[0] << " -> " << r4[0] << std::endl ;

  r4 = cos ( f4 ) ;
  std::cout << "cos " << f4[0] << " -> " << r4[0] << std::endl ;
}

compiled with:
clang++ -std=c++17 sincos.cc -osincos

Actual Results

sin 0.5 -> 0
cos 0.5 -> 1

compiled with g++ -std=c++17 sincos.cc -osincos
as expected:

Expected Results

sin 0.5 -> 0.479426
cos 0.5 -> 0.877583

@r-devulap
Copy link

It seems to be coming from here:

= __andnot(_S_signmask<_V>, _S_allbits<_V>);
.

The _andnot returns a 0 for _S_absmask with clang, the correct value should be 0x7FFFFFFF.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants