The code: void testit() { pragma(inline, false); short[4] arr = [-1, 6, 0, 4]; long1 A = *cast(long1*)(arr.ptr); assert(_mm_extract_pi16(A, 0) == 65535); // Error here } struct short4 { short[4] array; } struct long1 { long[1] array; } int _mm_extract_pi16 (long1 a, int imm8) { return cast(ushort)((cast(short4)a).array[imm8]); } The error is the optimizer incorrectly rewrites 65535 to be an unsigned short and then does a signed short comparison, which fails to match the left hand side which is a short. Should rewrite it as a short. void main() { testit(); }
@WalterBright created dlang/dmd pull request #12444 "fix Issue 21833 - Optimizer incorrectly rewrites integer comparison t…" fixing this issue: - fix Issue 21833 - Optimizer incorrectly rewrites integer comparison to unsigned short comparison https://github.com/dlang/dmd/pull/12444
dlang/dmd pull request #12444 "fix Issue 21833 - Optimizer incorrectly rewrites integer comparison t…" was merged into master: - 4adcfb79a21b01021589f99900e973fac1100820 by Walter Bright: fix Issue 21833 - Optimizer incorrectly rewrites integer comparison to unsigned short comparison https://github.com/dlang/dmd/pull/12444