www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23437] New: [CODEGEN][SIMD] Wrong codegen when inlining

https://issues.dlang.org/show_bug.cgi?id=23437

          Issue ID: 23437
           Summary: [CODEGEN][SIMD] Wrong codegen when inlining
                    __simd(XMM.SQRTSS, a)
           Product: D
           Version: D2
          Hardware: x86_64
                OS: All
            Status: NEW
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: aliloko gmail.com

Please consider the following program:

------------ main.d ---------------

import std.stdio;
import core.simd;

version(D_SIMD){}
else static assert(false);

float4 _mm_sqrt_ss(float4 a)
{
    return cast(float4) __simd(XMM.SQRTSS, a);    
}

void main(string[] args)
{
    float4 A = [4.0f, 4.0f, 4.0f, 4.0f];
    float4 B = _mm_sqrt_ss(A);
    writeln(B); // Displays [2, 4, 4, 4] but [2, 0, 0, 0] with -inline
}

------------------------------------

Built with:
    DMD -m64 main.d

Output is :
    [2, 4, 4, 4]

Built with:
    DMD -m64 -inline main.d
Output is :
    [2, 0, 0, 0]

--
Oct 25 2022