Bug 15144 – Bad operand size in asm { movdqa ... } produces bogus ubyte16 initializer error elsewhere.

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
All
Creation time
2015-10-03T16:34:00Z
Last change time
2016-10-01T11:46:14Z
Keywords
diagnostic, iasm, SIMD
Assigned to
nobody
Creator
Marco.Leise

Comments

Comment #0 by Marco.Leise — 2015-10-03T16:34:41Z
--- CODE --- void foo() { version (D_InlineAsm_X86_64) { alias csXMM = SSEFromString!`abc`; asm @nogc nothrow { movdqa XMM0, [csXMM]; } } else static assert(0, "Not implemented"); } template SSEFromString(string str) { import core.simd, std.algorithm, std.range; enum ubyte16 SSEFromString = chain(str, '\0'.repeat(ubyte16.sizeof - str.length)).array; } --- ---- --- Prints: Error: integer constant expression expected instead of cast(__vector(ubyte[16]))[cast(ubyte)97u, cast(ubyte)98u, cast(ubyte)99u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u] Error: bad type/size of operands 'movdqa' The nature of the message (hinting at incorrect initializer syntax) makes you think only integer constants are allowed in DMD as SIMD initializers, while in fact, fixing the asm-block will make the primary error go away and the code compile. (Does this message still make any sense at all with SIMD? DMD accepts other things than integer constants for a while now.)
Comment #1 by Marco.Leise — 2015-10-03T20:38:33Z
Ok, using `movdqa XMM0, csXMM;` it works when the `SSEFromString` is changed to declare the vector as __gshared instead of immutable. So DMD has trouble sorting things out when they are read-only data. void foo() { version (D_InlineAsm_X86_64) { alias csXMM = SSEFromString!`abc`; asm @nogc nothrow { movdqa XMM0, csXMM; } } else static assert(0, "Not implemented"); } template SSEFromString(string str) { import std.algorithm, std.range; version (DigitalMars) __gshared ubyte16 SIMDFromString = chain(str, '\0'.repeat(ubyte16.sizeof - str.length)).array; else immutable ubyte16 SIMDFromString = chain(str, '\0'.repeat(ubyte16.sizeof - str.length)).array; }
Comment #2 by bugzilla — 2016-04-20T09:33:40Z
A smaller test case: import core.simd; void foo() { enum ubyte16 csXMM1 = ['a','b','c',0,0,0,0,0]; __gshared ubyte16 csXMM2 = ['a','b','c',0,0,0,0,0]; immutable ubyte16 csXMM3 = ['a','b','c',0,0,0,0,0]; asm @nogc nothrow { movdqa XMM0, [csXMM1]; movdqa XMM0, [csXMM2]; movdqa XMM0, [csXMM3]; } }
Comment #3 by bugzilla — 2016-04-20T10:56:46Z
Comment #4 by github-bugzilla — 2016-04-22T20:20:50Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/2a74f6c70f335a6b46494ce684dcdbac9825a21b fix Issue 15144 - Bad operand size in asm { movdqa ... } produces bogus ubyte16 initializer error elsewhere https://github.com/dlang/dmd/commit/2f402fdc5b22020ccfc1f7d45b36f796825cd280 Merge pull request #5689 from WalterBright/fix15144 fix Issue 15144 - Bad operand size in asm { movdqa ... } produces bog…
Comment #5 by github-bugzilla — 2016-10-01T11:46:14Z
Commits pushed to stable at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/2a74f6c70f335a6b46494ce684dcdbac9825a21b fix Issue 15144 - Bad operand size in asm { movdqa ... } produces bogus ubyte16 initializer error elsewhere https://github.com/dlang/dmd/commit/2f402fdc5b22020ccfc1f7d45b36f796825cd280 Merge pull request #5689 from WalterBright/fix15144