public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug d/95174] New: [D] Incorrect compiled functions involving const fixed size arrays
@ 2020-05-17 12:07 witold.baryluk+gcc at gmail dot com
  2020-05-18 14:12 ` [Bug d/95174] " ibuclaw at gdcproject dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: witold.baryluk+gcc at gmail dot com @ 2020-05-17 12:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95174

            Bug ID: 95174
           Summary: [D] Incorrect compiled functions involving const fixed
                    size arrays
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: d
          Assignee: ibuclaw at gdcproject dot org
          Reporter: witold.baryluk+gcc at gmail dot com
  Target Milestone: ---

https://explore.dgnu.org/z/LppySp


```
void f(immutable(float[64]) x, float[64] o) {
   o[] = x[] * 2.0f;
}
```

and

```
void f(immutable(float[64]) x, float[64] o) {
    foreach (i; 0 .. 64) {
        o[i] = x[i] * 2.0f;
    }
}
```

and

```
void f(immutable(float[64]) x, float[64] o) {
    o[1] = x[5] + x[7];
}

```

Is incorrectly compiled to 'nop; ret'


It appears DMD (v2.092) also essentially do the same, and do not perform any
computations in the function.

LDC2 (1.20.1, based on DMD v2.090.1) does generate correct code in some cases
(fully unrolled and fully vectorized in this specific case), but in some other
also do nothing and simply does 'ret' in the function.



As a bonus:

```
void fffff(immutable(float[4]) x, float[4] o) {
   o[2] = x[1] + x[3];
}

import std.stdio : writeln;

void main() {
  immutable(float[4]) k = [7.0f, 5.3f, 1.2f, 3.2f];
  float[4] o;
  fffff(k, o);
  writeln(o);
}

```

prints '[nan, nan, nan, nan]', but it should: '[nan, nan, 8.5, nan]'.


I got the same results using my local gdc version 10.1.0 on amd64.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-05-19  3:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-17 12:07 [Bug d/95174] New: [D] Incorrect compiled functions involving const fixed size arrays witold.baryluk+gcc at gmail dot com
2020-05-18 14:12 ` [Bug d/95174] " ibuclaw at gdcproject dot org
2020-05-19  1:02 ` witold.baryluk+gcc at gmail dot com
2020-05-19  3:10 ` ibuclaw at gdcproject dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).