On Jan 2, 2025, at 4:00 PM, Sam James <s...@gentoo.org> wrote:
> 
> This testcase came up in a recent LLVM bug report [0] for DSE vs
> -ftrivial-auto-var-init=. Add it to our testsuite given that area
> could do with better coverage.
> 
> [0] https://github.com/llvm/llvm-project/issues/119646
> 
> gcc/testsuite/ChangeLog:
> 
>       * gcc.dg/torture/dse-trivial-auto-var-init.c: New test.
> 
> Co-authored-by: Andrew Pinski <pins...@gmail.com>
> ---
> OK?

Ok.  If a bug currently in gcc, would be nice to submit a bug report, get a 
number and attach it into the test case. If a bug in the past, would be nice to 
attach that number to it.

> .../gcc.dg/torture/dse-trivial-auto-var-init.c  | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
> create mode 100644 gcc/testsuite/gcc.dg/torture/dse-trivial-auto-var-init.c
> 
> diff --git a/gcc/testsuite/gcc.dg/torture/dse-trivial-auto-var-init.c 
> b/gcc/testsuite/gcc.dg/torture/dse-trivial-auto-var-init.c
> new file mode 100644
> index 000000000000..5a3d4c4e3ecb
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/torture/dse-trivial-auto-var-init.c
> @@ -0,0 +1,17 @@
> +/* Testcase for LLVM bug: https://github.com/llvm/llvm-project/issues/119646 
> */
> +/* { dg-do run } */
> +/* { dg-additional-options "-ftrivial-auto-var-init=zero" } */
> +
> +int b = 208;
> +[[gnu::noinline]]
> +void f(int *e, int a) {
> +  *e = !!b;
> +  if (a)
> +    __builtin_trap();
> +}
> +int main(void) {
> +  b = 0;
> +  f(&b, 0);
> +  if (b != 0)
> +    __builtin_trap();
> +}
> 
> base-commit: 99d5ef700619c28904846399a6f6692af4c56b1b
> -- 
> 2.47.1
> 

Reply via email to