www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19443] New: core.simd generates incorrect code


          Issue ID: 19443
           Summary: core.simd generates incorrect code
           Product: D
           Version: D2
          Hardware: x86_64
                OS: All
            Status: NEW
          Severity: minor
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: j.kulaviir gmail.com

Created attachment 1718
  --> https://issues.dlang.org/attachment.cgi?id=1718&action=edit
test case. includes both core.simd and inline assembly tests.

this one is sort of fun. the core.simd module seems to be producing unexpected
results, but only with the movhlps instruction, at least in so far as I have
seen. all other instructions that I have used, including movlhps, seem to be
working as expected.

for those not familiar with this instruction:

to elaborate: given inputs [1, 2, 4, 8] and [2, 3, 5, 7], the core.simd module
gives the result [2, 3, 4, 8]. when I dropped down to inline assembly though,
it produced the expected result of [5, 7, 4, 8]. attached is the test case. it
was compiled against dmd 2.83, the latest stable release at the time of this
writing, and was tested over several systems with varying amd and intel cpus.
all results were consistent - even from the interactive widget on the dlang.org

I did not try compiling it against ldc or gdc.

the documentation on the core.simd module is more or less non existent, so it's
possible that I may have missed something important. it's also possible that I
have no idea what I'm talking about, but either way it seems like a bug. I'm
not sure how often people muck around with simd stuff, so I marked it as minor,
but it'd be nice if someone would weigh in on this.

thanks everyone

Nov 28 2018