public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/112988] New: [14] RISC-V vector: Variadic function call causes runtime failure
@ 2023-12-12 18:17 patrick at rivosinc dot com
  2023-12-13 12:01 ` [Bug target/112988] " cvs-commit at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: patrick at rivosinc dot com @ 2023-12-12 18:17 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 112988
           Summary: [14] RISC-V vector: Variadic function call causes
                    runtime failure
           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 a = 0;
int p, q, r, x = 230;
short d;
int e[256];
static struct f w;
int *c = &r;

short y(short z) {
  return z * d;
}

#pragma pack(1)
struct f {
  int g;
  short h;
  int j;
  char k;
  char l;
  long m;
  long n;
  int o;
} s = {1}, v, t, *u = &v, *b = &s;

void add_em_up(int count, ...) {
  __builtin_va_list ap;
  __builtin_va_start(ap, count);
  __builtin_va_end(ap);
}

int main() {
  int i = 0;
  for (; i < 256; i++)
    e[i] = i;

  p = 0;
  for (; p <= 0; p++) {
    *c = 4;
    *u = t;
    x |= y(6 >= q);
  }

  *b = w;

  add_em_up(1, 1);

  if (a != 0)
    return 1;
  if (q != 0)
    return 2;
  if (p != 1)
    return 3;
  if (r != 4)
    return 4;
  if (x != 0xE6)
    return 5;
  if (d != 0)
    return 6;

  return 0;
}

Commands:
rv64gcv
> /scratch/tc-testing/tc-dec-11-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
> echo $?
3

rv64gc
> /scratch/tc-testing/tc-dec-11-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
> echo $?
0

Godbolt:
https://godbolt.org/z/Pq7Yns56G

Testcase seems very similar to pr112929, filing this bug to give people an
additional testcase to look at :)

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

* [Bug target/112988] [14] RISC-V vector: Variadic function call causes runtime failure
  2023-12-12 18:17 [Bug target/112988] New: [14] RISC-V vector: Variadic function call causes runtime failure patrick at rivosinc dot com
@ 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:21 ` patrick at rivosinc dot com
  2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-12-13 12:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Pan Li <panli@gcc.gnu.org>:

https://gcc.gnu.org/g:ef21ae5c45f3b79a36fadc1cb5723c095e2965ad

commit r14-6490-gef21ae5c45f3b79a36fadc1cb5723c095e2965ad
Author: Juzhe-Zhong <juzhe.zhong@rivai.ai>
Date:   Wed Dec 13 13:48:11 2023 +0800

    RISC-V: Postpone full available optimization [VSETVL PASS]

    Fix VSETVL BUG that AVL is polluted

    .L15:
            li      a3,9
            lui     a4,%hi(s)
            sw      a3,%lo(j)(t2)
            sh      a5,%lo(s)(a4) <--a4 is hold the address of s
            beq     t0,zero,.L42
            sw      t5,8(t4)
            vsetvli zero,a4,e8,m8,ta,ma  <<--- a4 as avl

    Actually, this vsetvl is redundant.
    The root cause we include full available optimization in LCM local data
computation.

    full available optimization should be after LCM computation.

            PR target/112929
            PR target/112988

    gcc/ChangeLog:

            * config/riscv/riscv-vsetvl.cc
            (pre_vsetvl::compute_lcm_local_properties): Remove full available.
            (pre_vsetvl::pre_global_vsetvl_info): Add full available
optimization.

    gcc/testsuite/ChangeLog:

            * gcc.target/riscv/rvv/vsetvl/pr112929.c: New test.
            * gcc.target/riscv/rvv/vsetvl/pr112988.c: New test.

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

* [Bug target/112988] [14] RISC-V vector: Variadic function call causes runtime failure
  2023-12-12 18:17 [Bug target/112988] New: [14] RISC-V vector: Variadic function call causes runtime failure patrick at rivosinc dot com
  2023-12-13 12:01 ` [Bug target/112988] " cvs-commit at gcc dot gnu.org
@ 2023-12-13 14:08 ` cvs-commit at gcc dot gnu.org
  2023-12-13 16:21 ` patrick at rivosinc dot com
  2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-12-13 14:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Pan Li <panli@gcc.gnu.org>:

https://gcc.gnu.org/g:d702387b1b765f85e19961a0b2a29df14df89bfd

commit r14-6497-gd702387b1b765f85e19961a0b2a29df14df89bfd
Author: Pan Li <pan2.li@intel.com>
Date:   Wed Dec 13 21:46:14 2023 +0800

    RISC-V: Refine test cases for both PR112929 and PR112988

    Refine the test cases for:

    * Name convention.
    * Add run case.

    These test cases used to cause out-of-bounds writes to the stack
    and therefore showed unreliable behavior.  Depending on the
    execution environment they can either pass or fail.  As of now,
    with the latest QEMU version, they will pass even without the
    underlying issue fixed.  As the test case is known to have
    caused the problem before we keep it as a run test case for
    future reference.

            PR target/112929
            PR target/112988

    gcc/testsuite/ChangeLog:

            * gcc.target/riscv/rvv/vsetvl/pr112929.c: Moved to...
            * gcc.target/riscv/rvv/vsetvl/pr112929-1.c: ...here.
            * gcc.target/riscv/rvv/vsetvl/pr112988.c: Moved to...
            * gcc.target/riscv/rvv/vsetvl/pr112988-1.c: ...here.
            * gcc.target/riscv/rvv/vsetvl/pr112929-2.c: New test.
            * gcc.target/riscv/rvv/vsetvl/pr112988-2.c: New test.

    Signed-off-by: Pan Li <pan2.li@intel.com>

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

* [Bug target/112988] [14] RISC-V vector: Variadic function call causes runtime failure
  2023-12-12 18:17 [Bug target/112988] New: [14] RISC-V vector: Variadic function call causes runtime failure patrick at rivosinc dot com
  2023-12-13 12:01 ` [Bug target/112988] " cvs-commit at gcc dot gnu.org
  2023-12-13 14:08 ` cvs-commit at gcc dot gnu.org
@ 2023-12-13 16:21 ` patrick at rivosinc dot com
  2 siblings, 0 replies; 4+ messages in thread
From: patrick at rivosinc dot com @ 2023-12-13 16:21 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick O'Neill <patrick at rivosinc dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from Patrick O'Neill <patrick at rivosinc dot com> ---
Confirmed to be fixed - thank you!

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

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-12 18:17 [Bug target/112988] New: [14] RISC-V vector: Variadic function call causes runtime failure patrick at rivosinc dot com
2023-12-13 12:01 ` [Bug target/112988] " cvs-commit at gcc dot gnu.org
2023-12-13 14:08 ` cvs-commit at gcc dot gnu.org
2023-12-13 16:21 ` 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).