int doubleAndSumInt(int4 v) { int sum = 0; foreach (ref e; v) sum += (e *= 2); return sum; }
Ah yes. I know about this one ;) I don't think it's important ... throw a -vcg-ast at it and you will see why it fails.
Replacing the v in the foreach with v.array will enable it to work. It's not documented to work without the .array, so I'm setting this as an enhancement request.
@WalterBright created dlang/dmd pull request #12065 "fix Issue 19632 - [SIMD] Error: invalid foreach aggregate" fixing this issue: - fix Issue 19632 - [SIMD] Error: invalid foreach aggregate https://github.com/dlang/dmd/pull/12065
dlang/dmd pull request #12065 "fix Issue 19632 - [SIMD] Error: invalid foreach aggregate" was merged into master: - cbb2d8f9a7eeadbd143d8ab4953c849c7e59454a by Walter Bright: fix Issue 19632 - [SIMD] Error: invalid foreach aggregate https://github.com/dlang/dmd/pull/12065