Bug 18034 – SIMD optimization issues

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2017-12-05T11:39:41Z
Last change time
2018-06-25T20:40:02Z
Keywords
wrong-code
Assigned to
No Owner
Creator
mmcomando

Attachments

IDFilenameSummaryContent-TypeSize
1666file_18034.txtCode that triggers bugtext/plain1003

Comments

Comment #0 by mmcomando — 2017-12-05T11:39:41Z
Created attachment 1666 Code that triggers bug Result of function changes if DMD optimization is enabled. $ dmd --version DMD64 D Compiler v2.077.1 Copyright (c) 1999-2017 by Digital Mars written by Walter Bright $ dmd test.d; ./test 11 true $ dmd -O test.d; ./test 0 false
Comment #1 by bitter.taste — 2018-02-19T17:20:34Z
The problem is quite subtle, after the glocal pass the following code ``` ushort8 v=ushort8(check); ubyte16 ok=__simd(XMM.PCMPEQW, control, v); ``` is turned into ``` ubyte16 ok=__simd(XMM.PCMPEQW, control, (ushort8 v = ushort8(check)); ``` and since `v' isn't used anywhere else in the code the rmdeadass pass removes the dead assignment by turning the expression into ``` ubyte16 ok=__simd(XMM.PCMPEQW, control, (<bogus>, void16(check))); ``` Now, the ushort8 -> void16 conversion happens because that's the type of the third argument of the __simd function and, as a result, the vector is initialized with the wrong elements, leading to the failure reported above.
Comment #2 by github-bugzilla — 2018-04-16T00:31:47Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/ba478b04139b8d4f7a42a35279f8089615156099 Fix issue 18034 - Bad codegen for OPvecfill Do not replace vector values if that implies a change of Ety, doing so may end up initializing the vector with the wrong content. https://github.com/dlang/dmd/commit/2493fb8bbea05d31a1fdae2a02d8eeae3ad0ff46 Merge pull request #7994 from LemonBoy/b18034 Fix issue 18034 - Bad codegen for OPvecfill merged-on-behalf-of: Mike Franklin <[email protected]>