public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/112929] New: [14] RISC-V vector: Variable clobbered at runtime
@ 2023-12-09  1:44 patrick at rivosinc dot com
  2023-12-09  2:01 ` [Bug target/112929] " pinskia at gcc dot gnu.org
                   ` (22 more replies)
  0 siblings, 23 replies; 24+ messages in thread
From: patrick at rivosinc dot com @ 2023-12-09  1:44 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 112929
           Summary: [14] RISC-V vector: Variable clobbered at runtime
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: patrick at rivosinc dot com
  Target Milestone: ---

Testcase:
int printf(char *, ...);
int a, b, l, i, p, q, t, n, o;
int *volatile c;
static int j;
static struct pack_1_struct d;
long e;
char m = 5;
short s;
#pragma pack(1)
struct pack_1_struct {
  long c;
  int d;
  int e;
  int f;
  int g;
  int h;
  int i;
} h, r = {1}, *f = &h, *volatile g;
int main() {
  int u;
  j = 0;
  for (; j < 9; ++j) {
    u = ++t ? a : 0;
    if (u) {
      int *v = &d.d;
      *v = g || e;
      *c = 0;
      *f = h;
    }
    s = l && c;
    o = i;
    d.f || (p = 0);
    q |= n;
  }
  r = *f;
  printf("b: %d\n", b);
  printf("m: %d\n", m);
}

Commands:
rv64gc:
> /scratch/tc-testing/tc-dec-8-trunk/build-rv64gcv/bin/riscv64-unknown-linux-gnu-gcc -march=rv64gc -mabi=lp64d -O3 red.c -o rv64gc.out
> QEMU_CPU=rv64,vlen=128,v=true,vext_spec=v1.0 /scratch/tc-testing/tc-dec-8-trunk/build-rv64gcv/bin/qemu-riscv64 rv64gc.out
b: 0
m: 5

rv64gcv:
> /scratch/tc-testing/tc-dec-8-trunk/build-rv64gcv/bin/riscv64-unknown-linux-gnu-gcc -march=rv64gcv -mabi=lp64d -O3 red.c -o rv64gcv.out
> QEMU_CPU=rv64,vlen=128,v=true,vext_spec=v1.0 /scratch/tc-testing/tc-dec-8-trunk/build-rv64gcv/bin/qemu-riscv64 rv64gcv.out
b: 0
m: 0

Nothing touches the m variable so at the end it should equal 5.

Commenting out the preceding printf("b: %d\n", b); statement causes the
testcase to pass successfully (and doesn't cause much change to the assembly):
https://godbolt.org/z/Erzzqxo8q

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

end of thread, other threads:[~2023-12-13 16:23 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-09  1:44 [Bug target/112929] New: [14] RISC-V vector: Variable clobbered at runtime patrick at rivosinc dot com
2023-12-09  2:01 ` [Bug target/112929] " pinskia at gcc dot gnu.org
2023-12-09  2:49 ` patrick at rivosinc dot com
2023-12-09  3:03 ` patrick at rivosinc dot com
2023-12-09  3:34 ` pinskia at gcc dot gnu.org
2023-12-09  3:38 ` pinskia at gcc dot gnu.org
2023-12-09 13:33 ` rdapp at gcc dot gnu.org
2023-12-09 13:40 ` rdapp at gcc dot gnu.org
2023-12-09 14:04 ` juzhe.zhong at rivai dot ai
2023-12-09 14:06 ` rdapp at gcc dot gnu.org
2023-12-09 14:18 ` juzhe.zhong at rivai dot ai
2023-12-10 12:41 ` pan2.li at intel dot com
2023-12-11  2:27 ` pan2.li at intel dot com
2023-12-11  8:03 ` rdapp at gcc dot gnu.org
2023-12-11 17:35 ` patrick at rivosinc dot com
2023-12-11 19:16 ` rdapp at gcc dot gnu.org
2023-12-11 19:41 ` patrick at rivosinc dot com
2023-12-11 19:42 ` patrick at rivosinc dot com
2023-12-12  5:51 ` pan2.li at intel dot com
2023-12-12  8:52 ` pan2.li at intel dot com
2023-12-12  9:06 ` kito at gcc dot gnu.org
2023-12-13 12:01 ` cvs-commit at gcc dot gnu.org
2023-12-13 14:08 ` cvs-commit at gcc dot gnu.org
2023-12-13 16:23 ` patrick at rivosinc dot com

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).