On Thursday, 7 September 2017 at 16:45:40 UTC, Igor wrote:
On Thursday, 7 September 2017 at 15:24:13 UTC, Johan Engelen wrote:
On Wednesday, 6 September 2017 at 20:43:01 UTC, Igor wrote:

I opened a feature request on github. I also tried using the gccbuiltins but I got this error:

LLVM ERROR: Cannot select: 0x2199c96fd70: v16i8 = X86ISD::PSHUFB 0x2199c74e9a8, 0x2199c74d6c0

That's because SSSE3 instructions are not enabled by default, so the compiler isn't allowed to generate the PSHUFB instruction.
Some options you have:
1. Set a cpu that has ssse3, e.g. compile with `-mcpu=native`
2. Enable SSSE3: compile with `-mattr=+ssse3`
3. Perhaps best for your case, enable SSSE3 for that function, importing the ldc.attributes module and using the @target("ssse3") UDA on that function.

-Johan

Thanks Johan. I tried this and now it does compile but it crashes with Access Violation in debug build. In optimized build it seems to be working though.

I will try to reproduce this in minimal project and open LDC bug if successful.

In the meantime can anyone tell me how to add an attribute to a function only if something is defined, since this doesn't work:

version(USE_SIMD_WITH_LDC) {
  import ldc.attributes;
  @target("ssse3")
} void funcThatUsesSIMD() {
  ...
  version(LDC) {
    import ldc.gccbuiltins_x86;
    c = __builtin_ia32_pshufb128(c, *simdMasks);
  } else {
    c = __simd(XMM.PSHUFB, c, *simdMasks);
  }
  ...
}

Reply via email to