aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg')
-rw-r--r--gcc/testsuite/gcc.dg/asm-hard-reg-1.c9
-rw-r--r--gcc/testsuite/gcc.dg/asm-hard-reg-2.c4
-rw-r--r--gcc/testsuite/gcc.dg/asm-hard-reg-4.c7
-rw-r--r--gcc/testsuite/gcc.dg/asm-hard-reg-5.c2
-rw-r--r--gcc/testsuite/gcc.dg/asm-hard-reg-6.c10
-rw-r--r--gcc/testsuite/gcc.dg/asm-hard-reg-error-3.c2
-rw-r--r--gcc/testsuite/gcc.dg/cpp/c2y-counter-1.c44
-rw-r--r--gcc/testsuite/gcc.dg/debug/ctf/ctf-array-7.c24
-rw-r--r--gcc/testsuite/gcc.dg/flex-array-counted-by-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/flex-array-counted-by.c2
-rw-r--r--gcc/testsuite/gcc.dg/gomp/adjust-args-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/gomp/append-args-1.c28
-rw-r--r--gcc/testsuite/gcc.dg/gomp/declare-variant-3.c18
-rw-r--r--gcc/testsuite/gcc.dg/gomp/pr121453.c18
-rw-r--r--gcc/testsuite/gcc.dg/gomp/unprototyped-variant.c30
-rw-r--r--gcc/testsuite/gcc.dg/graphite/id-30.c2
-rw-r--r--gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-no-show-nesting.c9
-rw-r--r--gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-show-nesting.c24
-rw-r--r--gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented-show-levels.c2
-rw-r--r--gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented-unicode.c2
-rw-r--r--gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented.c2
-rw-r--r--gcc/testsuite/gcc.dg/plugin/plugin.exp2
-rw-r--r--gcc/testsuite/gcc.dg/pointer-counted-by-1.c34
-rw-r--r--gcc/testsuite/gcc.dg/pointer-counted-by-2.c10
-rw-r--r--gcc/testsuite/gcc.dg/pointer-counted-by-3.c127
-rw-r--r--gcc/testsuite/gcc.dg/pointer-counted-by-4-char.c6
-rw-r--r--gcc/testsuite/gcc.dg/pointer-counted-by-4-float.c6
-rw-r--r--gcc/testsuite/gcc.dg/pointer-counted-by-4-struct.c10
-rw-r--r--gcc/testsuite/gcc.dg/pointer-counted-by-4-union.c10
-rw-r--r--gcc/testsuite/gcc.dg/pointer-counted-by-4.c77
-rw-r--r--gcc/testsuite/gcc.dg/pointer-counted-by-5.c56
-rw-r--r--gcc/testsuite/gcc.dg/pointer-counted-by-6.c56
-rw-r--r--gcc/testsuite/gcc.dg/pointer-counted-by-7.c32
-rw-r--r--gcc/testsuite/gcc.dg/pointer-counted-by-8.c29
-rw-r--r--gcc/testsuite/gcc.dg/pointer-counted-by-9.c85
-rw-r--r--gcc/testsuite/gcc.dg/pointer-counted-by.c111
-rw-r--r--gcc/testsuite/gcc.dg/pr109071.c43
-rw-r--r--gcc/testsuite/gcc.dg/pr109071_1.c36
-rw-r--r--gcc/testsuite/gcc.dg/pr109071_10.c85
-rw-r--r--gcc/testsuite/gcc.dg/pr109071_11.c89
-rw-r--r--gcc/testsuite/gcc.dg/pr109071_12.c44
-rw-r--r--gcc/testsuite/gcc.dg/pr109071_2.c50
-rw-r--r--gcc/testsuite/gcc.dg/pr109071_3.c42
-rw-r--r--gcc/testsuite/gcc.dg/pr109071_4.c41
-rw-r--r--gcc/testsuite/gcc.dg/pr109071_5.c33
-rw-r--r--gcc/testsuite/gcc.dg/pr109071_6.c49
-rw-r--r--gcc/testsuite/gcc.dg/pr109071_7.c44
-rw-r--r--gcc/testsuite/gcc.dg/pr109071_8.c51
-rw-r--r--gcc/testsuite/gcc.dg/pr109071_9.c61
-rw-r--r--gcc/testsuite/gcc.dg/pr117375.c13
-rw-r--r--gcc/testsuite/gcc.dg/pr118946-1.c15
-rw-r--r--gcc/testsuite/gcc.dg/pr120929.c49
-rw-r--r--gcc/testsuite/gcc.dg/pr121619.c33
-rw-r--r--gcc/testsuite/gcc.dg/pr89828.c49
-rw-r--r--gcc/testsuite/gcc.dg/pr94589-2.c88
-rw-r--r--gcc/testsuite/gcc.dg/pr94589-4.c84
-rw-r--r--gcc/testsuite/gcc.dg/pr94589-5.c80
-rw-r--r--gcc/testsuite/gcc.dg/pr94589-6.c166
-rw-r--r--gcc/testsuite/gcc.dg/torture/copy-prop-aggr-zero-1.c28
-rw-r--r--gcc/testsuite/gcc.dg/torture/copy-prop-aggr-zero-2.c28
-rw-r--r--gcc/testsuite/gcc.dg/torture/darwin-cfstring-3.c8
-rw-r--r--gcc/testsuite/gcc.dg/torture/hardbool-ai.c1
-rw-r--r--gcc/testsuite/gcc.dg/torture/malloc-1.c10
-rw-r--r--gcc/testsuite/gcc.dg/torture/malloc-2.c12
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr121279-1.c49
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr121422-1.c35
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr121422-2.c36
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr121478-1.c32
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr121514.c20
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr121656.c30
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr121695-1.c25
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-arg-1.c21
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-zero-1.c28
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-zero-2.c25
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-zero-3.c25
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-108.c30
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-109.c23
-rw-r--r--gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-2.c53
-rw-r--r--gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-3.c42
-rw-r--r--gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-4.c42
-rw-r--r--gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-5.c40
-rw-r--r--gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds.c46
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr121509.c42
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr121638.c74
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr121659.c11
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr121686.c32
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr121744-1.c13
87 files changed, 2870 insertions, 130 deletions
diff --git a/gcc/testsuite/gcc.dg/asm-hard-reg-1.c b/gcc/testsuite/gcc.dg/asm-hard-reg-1.c
index 6a5a9ad..8cefb6e 100644
--- a/gcc/testsuite/gcc.dg/asm-hard-reg-1.c
+++ b/gcc/testsuite/gcc.dg/asm-hard-reg-1.c
@@ -22,10 +22,11 @@
/* { dg-final { scan-assembler-times "foo\t%r4" 8 { target { s390*-*-* } } } } */
#elif defined (__x86_64__)
# define GPR "{rcx}"
-/* { dg-final { scan-assembler-times "foo\t%cl" 2 { target { x86_64-*-* } } } } */
-/* { dg-final { scan-assembler-times "foo\t%cx" 2 { target { x86_64-*-* } } } } */
-/* { dg-final { scan-assembler-times "foo\t%ecx" 2 { target { x86_64-*-* } } } } */
-/* { dg-final { scan-assembler-times "foo\t%rcx" 2 { target { x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "foo\t%cl" 2 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "foo\t%cx" 2 { target { i?86-*-* x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "foo\t%ecx" 2 { target { { i?86-*-* x86_64-*-* } && lp64 } } } } */
+/* { dg-final { scan-assembler-times "foo\t%rcx" 2 { target { { i?86-*-* x86_64-*-* } && lp64 } } } } */
+/* { dg-final { scan-assembler-times "foo\t%ecx" 4 { target { { i?86-*-* x86_64-*-* } && { ! lp64 } } } } } */
#endif
char
diff --git a/gcc/testsuite/gcc.dg/asm-hard-reg-2.c b/gcc/testsuite/gcc.dg/asm-hard-reg-2.c
index 7dabf96..5a60f9b 100644
--- a/gcc/testsuite/gcc.dg/asm-hard-reg-2.c
+++ b/gcc/testsuite/gcc.dg/asm-hard-reg-2.c
@@ -1,4 +1,4 @@
-/* { dg-do compile { target aarch64*-*-* powerpc64*-*-* riscv64-*-* s390*-*-* x86_64-*-* } } */
+/* { dg-do compile { target { { aarch64*-*-* powerpc64*-*-* riscv64-*-* s390*-*-* } || { { i?86-*-* x86_64-*-* } && { ! ia32 } } } } } */
/* { dg-options "-std=c99" } we need long long */
#if defined (__aarch64__)
@@ -15,7 +15,7 @@
/* { dg-final { scan-assembler-times "foo\t%r4" 2 { target { s390*-*-* } } } } */
#elif defined (__x86_64__)
# define GPR "{rcx}"
-/* { dg-final { scan-assembler-times "foo\t%rcx" 2 { target { x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "foo\t%rcx" 2 { target { i?86-*-* x86_64-*-* } } } } */
#endif
long long
diff --git a/gcc/testsuite/gcc.dg/asm-hard-reg-4.c b/gcc/testsuite/gcc.dg/asm-hard-reg-4.c
index 0134bf0..d319467 100644
--- a/gcc/testsuite/gcc.dg/asm-hard-reg-4.c
+++ b/gcc/testsuite/gcc.dg/asm-hard-reg-4.c
@@ -1,4 +1,5 @@
-/* { dg-do compile { target aarch64*-*-* arm*-*-* powerpc*-*-* riscv*-*-* s390*-*-* x86_64-*-* } } */
+/* { dg-do compile { target aarch64*-*-* arm*-*-* i?86-*-* powerpc*-*-* riscv*-*-* s390*-*-* x86_64-*-* } } */
+/* { dg-additional-options "-msse2" { target i?86-*-* x86_64-*-* } } */
#if defined (__aarch64__)
# define FPR "{d5}"
@@ -16,9 +17,9 @@
#elif defined (__s390__)
# define FPR "{f5}"
/* { dg-final { scan-assembler-times "foo\t%f5" 4 { target { s390*-*-* } } } } */
-#elif defined (__x86_64__)
+#elif defined (__i386__) || defined (__x86_64__)
# define FPR "{xmm5}"
-/* { dg-final { scan-assembler-times "foo\t%xmm5" 4 { target { x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "foo\t%xmm5" 4 { target { i?86-*-* x86_64-*-* } } } } */
#endif
float
diff --git a/gcc/testsuite/gcc.dg/asm-hard-reg-5.c b/gcc/testsuite/gcc.dg/asm-hard-reg-5.c
index a9e25ce..ea7907a 100644
--- a/gcc/testsuite/gcc.dg/asm-hard-reg-5.c
+++ b/gcc/testsuite/gcc.dg/asm-hard-reg-5.c
@@ -1,4 +1,4 @@
-/* { dg-do compile { target aarch64*-*-* powerpc64*-*-* riscv64-*-* s390*-*-* x86_64-*-* } } */
+/* { dg-do compile { target { { aarch64*-*-* powerpc64*-*-* riscv64-*-* s390*-*-* } || { { i?86-*-* x86_64-*-* } && { ! ia32 } } } } } */
typedef int V __attribute__ ((vector_size (4 * sizeof (int))));
diff --git a/gcc/testsuite/gcc.dg/asm-hard-reg-6.c b/gcc/testsuite/gcc.dg/asm-hard-reg-6.c
index d9b7fae..c87a811 100644
--- a/gcc/testsuite/gcc.dg/asm-hard-reg-6.c
+++ b/gcc/testsuite/gcc.dg/asm-hard-reg-6.c
@@ -19,8 +19,8 @@
# define GPR1 "{eax}"
# define GPR2 "{ebx}"
# define GPR3 "{ecx}"
-/* { dg-final { scan-assembler-times "foo\t4\\(%esp\\),%ecx" 1 { target { i?86-*-* } } } } */
-/* { dg-final { scan-assembler-times "bar\t%ebx,\\(%eax\\)" 1 { target { i?86-*-* } } } } */
+/* { dg-final { scan-assembler-times "foo\t4\\(%esp\\),%ecx" 1 { target { { i?86-*-* x86_64-*-* } && { ia32 } } } } } */
+/* { dg-final { scan-assembler-times "bar\t%ebx,\\(%eax\\)" 1 { target { { i?86-*-* x86_64-*-* } && { ia32 } } } } } */
#elif defined (__powerpc__) || defined (__POWERPC__)
# define GPR1 "{r4}"
# define GPR2 "{r5}"
@@ -43,8 +43,10 @@
# define GPR1 "{eax}"
# define GPR2 "{ebx}"
# define GPR3 "{rcx}"
-/* { dg-final { scan-assembler-times "foo\t%eax,%rcx" 1 { target { x86_64-*-* } } } } */
-/* { dg-final { scan-assembler-times "bar\t%ebx,\\(%rsi\\)" 1 { target { x86_64-*-* } } } } */
+/* { dg-final { scan-assembler-times "foo\t%eax,%rcx" 1 { target { { i?86-*-* x86_64-*-* } && lp64 } } } } */
+/* { dg-final { scan-assembler-times "bar\t%ebx,\\(%rsi\\)" 1 { target { { i?86-*-* x86_64-*-* } && lp64 } } } } */
+/* { dg-final { scan-assembler-times "foo\t%eax,%ecx" 1 { target { { i?86-*-* x86_64-*-* } && x32 } } } } */
+/* { dg-final { scan-assembler-times "bar\t%ebx,\\(%esi\\)" 1 { target { { i?86-*-* x86_64-*-* } && x32 } } } } */
#endif
void
diff --git a/gcc/testsuite/gcc.dg/asm-hard-reg-error-3.c b/gcc/testsuite/gcc.dg/asm-hard-reg-error-3.c
index 17b2317..b4254e3 100644
--- a/gcc/testsuite/gcc.dg/asm-hard-reg-error-3.c
+++ b/gcc/testsuite/gcc.dg/asm-hard-reg-error-3.c
@@ -1,6 +1,6 @@
/* { dg-do compile { target arm-*-* s390-*-* } } */
/* { dg-options "-std=c99" } we need long long */
-/* { dg-additional-options "-march=armv7-a" { target arm-*-* } } */
+/* { dg-additional-options "-march=armv7-a -marm" { target arm-*-* } } */
/* Test register pairs. */
diff --git a/gcc/testsuite/gcc.dg/cpp/c2y-counter-1.c b/gcc/testsuite/gcc.dg/cpp/c2y-counter-1.c
new file mode 100644
index 0000000..47d4b23
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/c2y-counter-1.c
@@ -0,0 +1,44 @@
+/* N3457 - The __COUNTER__ predefined macro */
+/* { dg-do run } */
+/* { dg-options "-std=c2y -pedantic-errors" } */
+
+#ifndef __COUNTER__
+#error "__COUNTER__ not defined"
+#endif
+
+#define A(X) X + X
+static_assert (A(__COUNTER__) == 0);
+#define B(X)
+B(__COUNTER__)
+static_assert (__COUNTER__ == 1);
+#define C(...) __VA_OPT__()
+C(__COUNTER__)
+static_assert (__COUNTER__ == 3);
+#define D(...) __VA_OPT__(a)
+int D(__COUNTER__) = 1;
+static_assert (__COUNTER__ == 5);
+#define E(X) #X
+const char *b = E(__COUNTER__);
+#define F(X) a##X
+int F(__COUNTER__) = 2;
+static_assert (__COUNTER__ == 6);
+#define G(X) b##X = X
+int G(__COUNTER__);
+static_assert (__COUNTER__ == 8);
+#if !defined(__COUNTER__) || (__COUNTER__ + 1 != __COUNTER__ + 0)
+#error "Unexpected __COUNTER__ behavior")
+#endif
+static_assert (__COUNTER__ == 11);
+
+extern int strcmp (const char *, const char *);
+extern void abort ();
+
+int
+main ()
+{
+ if (a != 1
+ || strcmp (b, "__COUNTER__")
+ || a__COUNTER__ != 2
+ || b__COUNTER__ != 7)
+ abort ();
+}
diff --git a/gcc/testsuite/gcc.dg/debug/ctf/ctf-array-7.c b/gcc/testsuite/gcc.dg/debug/ctf/ctf-array-7.c
new file mode 100644
index 0000000..f064f6f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/debug/ctf/ctf-array-7.c
@@ -0,0 +1,24 @@
+/* PR debug/121411
+ CTF generation for array which cannot be encoded in CTF.
+
+ CTF encoding uses a uint32 for number of elements in an array which
+ means there is a hard upper limit on sizes of arrays which can be
+ represented. Arrays with too many elements are encoded with
+ CTF_K_UNKNOWN to indicate that they cannot be represented. */
+
+/* { dg-do compile { target { lp64 || llp64 } } } */
+/* { dg-options "-O0 -gctf -dA" } */
+
+int rep[0xffffffff];
+int unrep[0x100000000];
+
+/* One dimension can be represented, other cannot.
+ Result is a (representable) array with unknown element type. */
+int unrepdim [0xab][0x100000007];
+
+/* Two CTF_K_ARRAY, one (shared) CTF_K_UNKNOWN. */
+/* { dg-final { scan-assembler-times "0x12000000\[\t \]+\[^\n\]*ctt_info" 2 } } */
+/* { dg-final { scan-assembler-times "0x2000000\[\t \]+\[^\n\]*ctt_info" 1 } } */
+
+/* { dg-final { scan-assembler-times "\[\t \]+0xffffffff\[\t \]+\[^\n\]*cta_nelems" 1 } } */
+/* { dg-final { scan-assembler-times "\[\t \]+0xab\[\t \]+\[^\n\]*cta_nelems" 1 } } */
diff --git a/gcc/testsuite/gcc.dg/flex-array-counted-by-2.c b/gcc/testsuite/gcc.dg/flex-array-counted-by-2.c
index 42d6436..a9bec2d 100644
--- a/gcc/testsuite/gcc.dg/flex-array-counted-by-2.c
+++ b/gcc/testsuite/gcc.dg/flex-array-counted-by-2.c
@@ -111,4 +111,4 @@ int main(int argc, char *argv[])
return 0;
}
-/* { dg-final { scan-tree-dump-times "ACCESS_WITH_SIZE" 8 "original" } } */
+/* { dg-final { scan-tree-dump-times "ACCESS_WITH_SIZE" 6 "original" } } */
diff --git a/gcc/testsuite/gcc.dg/flex-array-counted-by.c b/gcc/testsuite/gcc.dg/flex-array-counted-by.c
index 16eb2c6..4fa91ff 100644
--- a/gcc/testsuite/gcc.dg/flex-array-counted-by.c
+++ b/gcc/testsuite/gcc.dg/flex-array-counted-by.c
@@ -10,7 +10,7 @@ int x __attribute ((counted_by (size))); /* { dg-error "attribute is not allowed
struct trailing {
int count;
- int field __attribute ((counted_by (count))); /* { dg-error "attribute is not allowed for a non-array field" } */
+ int field __attribute ((counted_by (count))); /* { dg-error "attribute is not allowed for a non-array or non-pointer field" } */
};
struct trailing_1 {
diff --git a/gcc/testsuite/gcc.dg/gomp/adjust-args-1.c b/gcc/testsuite/gcc.dg/gomp/adjust-args-1.c
index 90787ef..d67db5e 100644
--- a/gcc/testsuite/gcc.dg/gomp/adjust-args-1.c
+++ b/gcc/testsuite/gcc.dg/gomp/adjust-args-1.c
@@ -11,7 +11,7 @@ int f1 (int);
int f2 (void *a);
#pragma omp declare variant (f1) match (construct={dispatch}) adjust_args (other: a) /* { dg-error "expected 'nothing' or 'need_device_ptr'" } */
int f3 (int a);
-#pragma omp declare variant (f0) adjust_args (nothing: a) /* { dg-error "an 'adjust_args' clause requires a 'match' clause" } */
+#pragma omp declare variant (f0) adjust_args (nothing: a) /* { dg-error "expected 'match' clause" } */
int f4 (void *a);
#pragma omp declare variant (f1) match (construct={dispatch}) adjust_args () /* { dg-error "expected 'nothing' or 'need_device_ptr' followed by ':'" } */
int f5 (int a);
diff --git a/gcc/testsuite/gcc.dg/gomp/append-args-1.c b/gcc/testsuite/gcc.dg/gomp/append-args-1.c
index 81dd106..15fc752 100644
--- a/gcc/testsuite/gcc.dg/gomp/append-args-1.c
+++ b/gcc/testsuite/gcc.dg/gomp/append-args-1.c
@@ -15,56 +15,60 @@ typedef enum omp_interop_t
} omp_interop_t;
-/* (A) No prototype for the variant but for the base function. */
+/* (A) No prototype for the variant but for the base function.
+ This is OK, the unprototyped decl is compatible with the modified
+ argument list. */
void variant_fn1();
#pragma omp declare variant(variant_fn1) match(construct={dispatch}) append_args(interop(target)) \
adjust_args(need_device_ptr: x,y)
void bar1(int *x, int *y);
-/* { dg-error "variant 'variant_fn1' and base 'bar1' have incompatible types" "" { target *-*-* } .-3 } */
void variant_fn2();
#pragma omp declare variant(variant_fn2) match(construct={dispatch}) append_args(interop(target))
void bar2(int *x, int *y);
-/* { dg-error "variant 'variant_fn2' and base 'bar2' have incompatible types" "" { target *-*-* } .-2 } */
-/* (B) No prototype for the variant nor for the base function. */
+/* (B) No prototype for the variant nor for the base function.
+ The declarations are compatible, but adjust_args requires a prototyped
+ base function so that we know where in the arglist to insert the additional
+ omp_interop_t arguments. */
-void variant_fn3(); /* { dg-error "argument 1 of 'variant_fn3' must be of 'omp_interop_t'" } */
+void variant_fn3();
#pragma omp declare variant(variant_fn3) match(construct={dispatch}) append_args(interop(target)) \
adjust_args(need_device_ptr: x,y)
void bar3();
/* { dg-error "'x' undeclared here \\(not in a function\\)" "" { target *-*-* } .-2 } */
/* { dg-error "'y' undeclared here \\(not in a function\\)" "" { target *-*-* } .-3 } */
-/* { dg-note "'append_args' specified here" "" { target *-*-* } .-5 } */
+/* { dg-message "'append_args' with unprototyped base function" "" { target *-*-* } .-5 } */
-void variant_fn4(); /* { dg-error "argument 1 of 'variant_fn4' must be of 'omp_interop_t'" } */
+void variant_fn4();
#pragma omp declare variant(variant_fn4) match(construct={dispatch}) append_args(interop(target))
void bar4();
-/* { dg-note "'append_args' specified here" "" { target *-*-* } .-2 } */
+/* { dg-message "'append_args' with unprototyped base function" "" { target *-*-* } .-2 } */
-/* (C) Only a prototype on the variant-function side. */
+/* (C) Only a prototype on the variant-function side. Again, the base
+ function requires a prototype with append_args. */
void variant_fn5(omp_interop_t, omp_interop_t);
#pragma omp declare variant(variant_fn5) match(construct={dispatch}) append_args(interop(target)) \
adjust_args(need_device_ptr: x,y)
void bar5();
-/* { dg-error "variant 'variant_fn5' and base 'bar5' have incompatible types" "" { target *-*-* } .-3 } */
+/* { dg-message "'append_args' with unprototyped base function" "" { target *-*-* } .-3 } */
void variant_fn6(omp_interop_t, omp_interop_t);
#pragma omp declare variant(variant_fn6) match(construct={dispatch}) append_args(interop(target))
void bar6();
-/* { dg-error "variant 'variant_fn6' and base 'bar6' have incompatible types" "" { target *-*-* } .-2 } */
+/* { dg-message "'append_args' with unprototyped base function" "" { target *-*-* } .-2 } */
void variant_fn7(int *, int, omp_interop_t, omp_interop_t);
#pragma omp declare variant(variant_fn7) match(construct={dispatch}) append_args(interop(target))
void bar7();
-/* { dg-error "variant 'variant_fn7' and base 'bar7' have incompatible types" "" { target *-*-* } .-2 } */
+/* { dg-message "'append_args' with unprototyped base function" "" { target *-*-* } .-2 } */
diff --git a/gcc/testsuite/gcc.dg/gomp/declare-variant-3.c b/gcc/testsuite/gcc.dg/gomp/declare-variant-3.c
new file mode 100644
index 0000000..92b71fe
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gomp/declare-variant-3.c
@@ -0,0 +1,18 @@
+/* PR118839: Check that error is diagnosed when the variant is the same as
+ the base function. */
+
+/* No previous declaration. */
+#pragma omp declare variant(f) match(user={condition(1)}) /* { dg-error "variant 'f' is the same as base function" } */
+void f(int *x);
+
+/* Previous declaration. */
+void g(int *x)
+{
+ *x = 42;
+}
+
+#pragma omp declare variant(g) match(user={condition(1)}) /* { dg-error "variant 'g' is the same as base function" } */
+void g(int *x);
+
+
+
diff --git a/gcc/testsuite/gcc.dg/gomp/pr121453.c b/gcc/testsuite/gcc.dg/gomp/pr121453.c
new file mode 100644
index 0000000..74014e6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gomp/pr121453.c
@@ -0,0 +1,18 @@
+/* PR middle-end/121453 */
+/* { dg-do compile } */
+/* { dg-options "-fopenmp -O2 -Wuninitialized" } */
+
+void bar (int, int, int);
+int v[40][40][40];
+
+void
+foo (int x, int y, int z)
+{
+ int i, j, k;
+#pragma omp parallel for simd collapse(3)
+ for (k = 1; k <= z; ++k)
+ for (j = 2; j <= y - 1; ++j)
+ for (i = 1; i <= x; ++i)
+ v[i][j][k] = 0;
+ bar (i, j, k);
+}
diff --git a/gcc/testsuite/gcc.dg/gomp/unprototyped-variant.c b/gcc/testsuite/gcc.dg/gomp/unprototyped-variant.c
new file mode 100644
index 0000000..ca84775
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gomp/unprototyped-variant.c
@@ -0,0 +1,30 @@
+/* { dg-additional-options "-std=gnu90" } */
+
+/* This test case used to ICE in the gimplifier after issuing a
+ different diagnostic message. */
+
+#if __cplusplus >= 201103L
+# define __GOMP_UINTPTR_T_ENUM : __UINTPTR_TYPE__
+#else
+# define __GOMP_UINTPTR_T_ENUM
+#endif
+
+typedef enum omp_interop_t __GOMP_UINTPTR_T_ENUM
+{
+ omp_interop_none = 0,
+ __omp_interop_t_max__ = __UINTPTR_MAX__
+} omp_interop_t;
+
+
+void g2();
+#pragma omp declare variant(g2) match(construct={dispatch}) append_args(interop(target,targetsync)) /* { dg-message "'append_args' with unprototyped base function" } */
+void f2();
+
+void foo()
+{
+ omp_interop_t obj6 = omp_interop_none;
+ const char *cp = 0L;
+
+ #pragma omp dispatch interop(obj6)
+ f2(5, cp);
+}
diff --git a/gcc/testsuite/gcc.dg/graphite/id-30.c b/gcc/testsuite/gcc.dg/graphite/id-30.c
index f8144ce..91838ed 100644
--- a/gcc/testsuite/gcc.dg/graphite/id-30.c
+++ b/gcc/testsuite/gcc.dg/graphite/id-30.c
@@ -1,5 +1,5 @@
/* The modulo constraints we generate for the niter expression
- (unsinged long)ubound - (unsigned long)lbound
+ (unsigned long)ubound - (unsigned long)lbound
end up with a modulo that we cannot represent in the expression
type we are using (int64_t), so we run into the codegen error
where ISL generates a modulo/divide by sth that doesn't fit the
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-no-show-nesting.c b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-no-show-nesting.c
new file mode 100644
index 0000000..3492899
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-no-show-nesting.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-fno-diagnostics-show-nesting" } */
+
+extern void foo (void);
+
+void test_nesting (void)
+{
+ foo (); /* { dg-error "top-level error" } */
+}
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-show-nesting.c b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-show-nesting.c
new file mode 100644
index 0000000..8fc2edb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-show-nesting.c
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-options "-fdiagnostics-show-nesting" } */
+
+extern void foo (void);
+
+void test_nesting (void)
+{
+ foo (); /* { dg-error "top-level error" } */
+}
+
+/* { dg-begin-multiline-output "" }
+ * child 0
+ * grandchild 0 0
+ * grandchild 0 1
+ * grandchild 0 2
+ * child 1
+ * grandchild 1 0
+ * grandchild 1 1
+ * grandchild 1 2
+ * child 2
+ * grandchild 2 0
+ * grandchild 2 1
+ * grandchild 2 2
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented-show-levels.c b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented-show-levels.c
index f44c8eb..4be52fe 100644
--- a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented-show-levels.c
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented-show-levels.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-fdiagnostics-set-output=text:experimental-nesting=yes,experimental-nesting-show-levels=yes" } */
+/* { dg-options "-fdiagnostics-set-output=text:show-nesting=yes,show-nesting-levels=yes" } */
extern void foo (void);
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented-unicode.c b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented-unicode.c
index 39e29f7..c069c3f 100644
--- a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented-unicode.c
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented-unicode.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-fdiagnostics-set-output=text:experimental-nesting=yes -fdiagnostics-text-art-charset=unicode" } */
+/* { dg-options "-fdiagnostics-set-output=text:show-nesting=yes -fdiagnostics-text-art-charset=unicode" } */
extern void foo (void);
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented.c b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented.c
index e103429..a35254d 100644
--- a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented.c
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-nesting-text-indented.c
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-fdiagnostics-set-output=text:experimental-nesting=yes" } */
+/* { dg-options "-fdiagnostics-set-output=text:show-nesting=yes" } */
extern void foo (void);
diff --git a/gcc/testsuite/gcc.dg/plugin/plugin.exp b/gcc/testsuite/gcc.dg/plugin/plugin.exp
index 3bb6063..c7cc36c 100644
--- a/gcc/testsuite/gcc.dg/plugin/plugin.exp
+++ b/gcc/testsuite/gcc.dg/plugin/plugin.exp
@@ -112,6 +112,8 @@ set plugin_test_list [list \
diagnostic-test-graphs-html.c \
diagnostic-test-graphs-sarif.c } \
{ diagnostic_plugin_test_nesting.cc \
+ diagnostic-test-nesting-show-nesting.c \
+ diagnostic-test-nesting-no-show-nesting.c \
diagnostic-test-nesting-text-plain.c \
diagnostic-test-nesting-text-indented.c \
diagnostic-test-nesting-text-indented-show-levels.c \
diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-1.c b/gcc/testsuite/gcc.dg/pointer-counted-by-1.c
new file mode 100644
index 0000000..395af34
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-counted-by-1.c
@@ -0,0 +1,34 @@
+/* More testing the correct usage of attribute counted_by for pointer field. */
+/* { dg-do compile } */
+/* { dg-options "-O0" } */
+
+typedef struct item1 Item1;
+typedef union item2 Item2;
+
+struct pointer_array {
+ int count1;
+ Item1 *array_1 __attribute__ ((counted_by (count1)));
+ Item2 *array_2 __attribute__ ((counted_by (count2)));
+ int count2;
+} *pointer_data;
+
+struct item1 {
+ int a;
+ float b[];
+};
+
+union item2 {
+ int c;
+ float d[];
+};
+
+void foo ()
+{
+ pointer_data
+ = (struct pointer_array *) __builtin_malloc (sizeof (struct pointer_array));
+ pointer_data->array_1 /* { dg-error "attribute is not allowed for a pointer to structure or union with flexible array member" } */
+ = (Item1 *) __builtin_malloc (sizeof (Item1) + 3 * sizeof (float));
+ pointer_data->array_2 /* { dg-error "attribute is not allowed for a pointer to structure or union with flexible array member" } */
+ = (Item2 *) __builtin_malloc (sizeof (Item2) + 3 * sizeof (float));
+ return;
+}
diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-2.c b/gcc/testsuite/gcc.dg/pointer-counted-by-2.c
new file mode 100644
index 0000000..1f4a278
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-counted-by-2.c
@@ -0,0 +1,10 @@
+/* Testing the correct usage of attribute counted_by for pointer: _BitInt */
+/* { dg-do compile { target bitint } } */
+/* { dg-options "-O2 -std=c23" } */
+
+struct pointer_array {
+ _BitInt(24) count;
+ int *array __attribute__ ((counted_by (count)));
+ int *array1 __attribute__ ((counted_by (count1)));
+ _BitInt(24) count1;
+};
diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-3.c b/gcc/testsuite/gcc.dg/pointer-counted-by-3.c
new file mode 100644
index 0000000..7005609
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-counted-by-3.c
@@ -0,0 +1,127 @@
+ /* Testing the correct usage of attribute counted_by for pointer in c23,
+ multiple definitions of the same tag in same or different scopes.
+ { dg-do compile }
+ { dg-options "-std=c23" }
+ */
+
+/* Allowed redefinitions of the same struct in the same scope, with the
+ same counted_by attribute. */
+struct f {
+ int b;
+ int c;
+ int *a __attribute__ ((counted_by (b))); };
+struct f {
+ int b;
+ int c;
+ int *a __attribute__ ((counted_by (b))); };
+struct f {
+ int b;
+ int c;
+ int *a; }; /* { dg-error "redefinition of struct or union" } */
+
+/* Error when the counted_by attribute is defined differently. */
+struct f {
+ int b;
+ int c;
+ int *a __attribute__ ((counted_by (c))); }; /* { dg-error "redefinition of struct or union" } */
+
+struct h {
+ int b;
+ int c;
+ int *a __attribute__ ((counted_by (b))); } p;
+
+void test (void)
+{
+ struct h {
+ int b;
+ int c;
+ int *a __attribute__ ((counted_by (b))); } x;
+
+ p = x;
+}
+
+void test1 (void)
+{
+ struct h {
+ int b;
+ int c;
+ int *a __attribute__ ((counted_by (c))); } y;
+
+ p = y; /* { dg-error "incompatible types when assigning to type" } */
+}
+
+struct nested_f {
+ struct {
+ union {
+ int b;
+ float f;
+ };
+ int n;
+ };
+ char *c __attribute__ ((counted_by (b)));
+};
+
+struct nested_f {
+ struct {
+ union {
+ int b;
+ float f;
+ };
+ int n;
+ };
+ char *c __attribute__ ((counted_by (b)));
+};
+
+struct nested_f {
+ struct {
+ union {
+ int b;
+ float f;
+ };
+ int n;
+ };
+ char *c __attribute__ ((counted_by (n)));
+}; /* { dg-error "redefinition of struct or union" } */
+
+struct nested_h {
+ struct {
+ union {
+ int b;
+ float f;
+ };
+ int n;
+ };
+ char *c __attribute__ ((counted_by (b)));
+} nested_p;
+
+void test_2 (void)
+{
+struct nested_h {
+ struct {
+ union {
+ int b;
+ float f;
+ };
+ int n;
+ };
+ char *c __attribute__ ((counted_by (b)));
+} nested_x;
+
+ nested_p = nested_x;
+}
+
+void test_3 (void)
+{
+struct nested_h {
+ struct {
+ union {
+ int b;
+ float f;
+ };
+ int n;
+ };
+ char *c __attribute__ ((counted_by (n)));
+} nested_y;
+
+ nested_p = nested_y; /* { dg-error "incompatible types when assigning to type" } */
+}
diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-4-char.c b/gcc/testsuite/gcc.dg/pointer-counted-by-4-char.c
new file mode 100644
index 0000000..c404e5b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-counted-by-4-char.c
@@ -0,0 +1,6 @@
+/* Test the attribute counted_by for pointer field and its usage in
+ * __builtin_dynamic_object_size. */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+#define PTR_TYPE char
+#include "pointer-counted-by-4.c"
diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-4-float.c b/gcc/testsuite/gcc.dg/pointer-counted-by-4-float.c
new file mode 100644
index 0000000..383d8fb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-counted-by-4-float.c
@@ -0,0 +1,6 @@
+/* Test the attribute counted_by for pointer field and its usage in
+ * __builtin_dynamic_object_size. */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+#define PTR_TYPE float
+#include "pointer-counted-by-4.c"
diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-4-struct.c b/gcc/testsuite/gcc.dg/pointer-counted-by-4-struct.c
new file mode 100644
index 0000000..50246d2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-counted-by-4-struct.c
@@ -0,0 +1,10 @@
+/* Test the attribute counted_by for pointer field and its usage in
+ * __builtin_dynamic_object_size. */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+struct A {
+ int a;
+ char *b;
+};
+#define PTR_TYPE struct A
+#include "pointer-counted-by-4.c"
diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-4-union.c b/gcc/testsuite/gcc.dg/pointer-counted-by-4-union.c
new file mode 100644
index 0000000..e786d99
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-counted-by-4-union.c
@@ -0,0 +1,10 @@
+/* Test the attribute counted_by for pointer field and its usage in
+ * __builtin_dynamic_object_size. */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+union A {
+ int a;
+ float b;
+};
+#define PTR_TYPE union A
+#include "pointer-counted-by-4.c"
diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-4.c b/gcc/testsuite/gcc.dg/pointer-counted-by-4.c
new file mode 100644
index 0000000..c4b3631
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-counted-by-4.c
@@ -0,0 +1,77 @@
+/* Test the attribute counted_by for pointer field and its usage in
+ * __builtin_dynamic_object_size. */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+#include "builtin-object-size-common.h"
+#ifndef PTR_TYPE
+#define PTR_TYPE int
+#endif
+struct pointer_array {
+ int b;
+ PTR_TYPE *c;
+} *p_array;
+
+struct annotated {
+ PTR_TYPE *c __attribute__ ((counted_by (b)));
+ int b;
+} *p_array_annotated;
+
+struct nested_annotated {
+ PTR_TYPE *c __attribute__ ((counted_by (b)));
+ struct {
+ union {
+ int b;
+ float f;
+ };
+ int n;
+ };
+} *p_array_nested_annotated;
+
+void __attribute__((__noinline__)) setup (int normal_count, int attr_count)
+{
+ p_array
+ = (struct pointer_array *) malloc (sizeof (struct pointer_array));
+ p_array->c = (PTR_TYPE *) malloc (sizeof (PTR_TYPE) * normal_count);
+ p_array->b = normal_count;
+
+ p_array_annotated
+ = (struct annotated *) malloc (sizeof (struct annotated));
+ p_array_annotated->c = (PTR_TYPE *) malloc (sizeof (PTR_TYPE) * attr_count);
+ p_array_annotated->b = attr_count;
+
+ p_array_nested_annotated
+ = (struct nested_annotated *) malloc (sizeof (struct nested_annotated));
+ p_array_nested_annotated->c = (PTR_TYPE *) malloc (sizeof (PTR_TYPE) * attr_count);
+ p_array_nested_annotated->b = attr_count;
+
+ return;
+}
+
+void __attribute__((__noinline__)) test ()
+{
+ EXPECT(__builtin_dynamic_object_size(p_array->c, 1), -1);
+ EXPECT(__builtin_dynamic_object_size(p_array_annotated->c, 1),
+ p_array_annotated->b * sizeof (PTR_TYPE));
+ EXPECT(__builtin_dynamic_object_size(p_array_nested_annotated->c, 1),
+ p_array_nested_annotated->b * sizeof (PTR_TYPE));
+}
+
+void cleanup ()
+{
+ free (p_array->c);
+ free (p_array);
+ free (p_array_annotated->c);
+ free (p_array_annotated);
+ free (p_array_nested_annotated->c);
+ free (p_array_nested_annotated);
+}
+
+int main(int argc, char *argv[])
+{
+ setup (10,10);
+ test ();
+ DONE ();
+ cleanup ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-5.c b/gcc/testsuite/gcc.dg/pointer-counted-by-5.c
new file mode 100644
index 0000000..b43ffdf
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-counted-by-5.c
@@ -0,0 +1,56 @@
+/* Test the attribute counted_by for pointer fields and its usage in
+ * __builtin_dynamic_object_size: when the counted_by field is negative. */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+#include "builtin-object-size-common.h"
+
+struct annotated {
+ int b;
+ int *c __attribute__ ((counted_by (b)));
+} *array_annotated;
+
+struct nested_annotated {
+ int *c __attribute__ ((counted_by (b)));
+ struct {
+ union {
+ int b;
+ float f;
+ };
+ int n;
+ };
+} *array_nested_annotated;
+
+void __attribute__((__noinline__)) setup (int attr_count)
+{
+ array_annotated
+ = (struct annotated *)malloc (sizeof (struct annotated));
+ array_annotated->b = attr_count;
+
+ array_nested_annotated
+ = (struct nested_annotated *)malloc (sizeof (struct nested_annotated));
+ array_nested_annotated->b = attr_count - 1;
+
+ return;
+}
+
+void __attribute__((__noinline__)) test ()
+{
+ EXPECT(__builtin_dynamic_object_size(array_annotated->c, 1), 0);
+ EXPECT(__builtin_dynamic_object_size(array_nested_annotated->c, 1), 0);
+}
+
+void cleanup ()
+{
+ free (array_annotated);
+ free (array_nested_annotated);
+}
+
+int main(int argc, char *argv[])
+{
+ setup (-10);
+ test ();
+ DONE ();
+ cleanup ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-6.c b/gcc/testsuite/gcc.dg/pointer-counted-by-6.c
new file mode 100644
index 0000000..355558c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-counted-by-6.c
@@ -0,0 +1,56 @@
+/* Test the attribute counted_by for pointer fields and its usage in
+ * __builtin_dynamic_object_size: when the type of the pointer
+ * is casting to another type. */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+#include "builtin-object-size-common.h"
+
+typedef unsigned short u16;
+
+struct info {
+ u16 data_len;
+ char *data __attribute__((counted_by(data_len)));
+};
+
+struct foo {
+ int a;
+ int b;
+};
+
+static __attribute__((__noinline__))
+struct info *setup ()
+{
+ struct info *p;
+ size_t bytes = 3 * sizeof(struct foo);
+
+ p = (struct info *) malloc (sizeof (struct info));
+ p->data = (char *) malloc (bytes);
+ p->data_len = bytes;
+
+ return p;
+}
+
+static void
+__attribute__((__noinline__)) report (struct info *p)
+{
+ struct foo *bar = (struct foo *)p->data;
+ EXPECT(__builtin_dynamic_object_size((char *)(bar + 1), 1),
+ sizeof (struct foo) * 2);
+ EXPECT(__builtin_dynamic_object_size((char *)(bar + 2), 1),
+ sizeof (struct foo));
+}
+
+void cleanup (struct info *p)
+{
+ free (p->data);
+ free (p);
+}
+
+int main(int argc, char *argv[])
+{
+ struct info *p = setup();
+ report(p);
+ cleanup (p);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-7.c b/gcc/testsuite/gcc.dg/pointer-counted-by-7.c
new file mode 100644
index 0000000..af1ab27
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-counted-by-7.c
@@ -0,0 +1,32 @@
+/* Additional test of the attribute counted_by for pointer field and its usage
+ in __builtin_dynamic_object_size. */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+#include "builtin-object-size-common.h"
+
+struct annotated {
+ int b;
+ int *c __attribute__ ((counted_by (b)));
+};
+
+struct annotated __attribute__((__noinline__)) setup (int attr_count)
+{
+ struct annotated p_array_annotated;
+ p_array_annotated.c = (int *) malloc (sizeof (int) * attr_count);
+ p_array_annotated.b = attr_count;
+
+ return p_array_annotated;
+}
+
+int main(int argc, char *argv[])
+{
+ struct annotated x = setup (10);
+ int *p = x.c;
+ x = setup (20);
+ EXPECT(__builtin_dynamic_object_size (p, 1), 10 * sizeof (int));
+ EXPECT(__builtin_dynamic_object_size (x.c, 1), 20 * sizeof (int));
+ free (p);
+ free (x.c);
+ DONE ();
+}
diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-8.c b/gcc/testsuite/gcc.dg/pointer-counted-by-8.c
new file mode 100644
index 0000000..96bb83f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-counted-by-8.c
@@ -0,0 +1,29 @@
+/* Additional test of the attribute counted_by for pointer field and its usage
+ in __builtin_dynamic_object_size. */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+#include "builtin-object-size-common.h"
+
+struct annotated {
+ int b;
+ int *c __attribute__ ((counted_by (b)));
+};
+
+
+void __attribute__((__noinline__)) setup (int **ptr, int attr_count)
+{
+ *ptr = (int *) malloc (sizeof (int) * attr_count);
+}
+
+int main(int argc, char *argv[])
+{
+ struct annotated *f
+ = (struct annotated *) __builtin_malloc (sizeof (struct annotated));
+ setup (&f->c, 10);
+ f->b = 10;
+ EXPECT(__builtin_dynamic_object_size (f->c, 1), 10 * sizeof (int));
+ free (f->c);
+ free (f);
+ DONE ();
+}
diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-9.c b/gcc/testsuite/gcc.dg/pointer-counted-by-9.c
new file mode 100644
index 0000000..a0ca0a2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-counted-by-9.c
@@ -0,0 +1,85 @@
+/* Test the code generation for the new attribute counted_by.
+ And also the offsetof operator on such array. */
+/* { dg-do run } */
+/* { dg-options "-O2 -fdump-tree-original" } */
+
+#include <stdlib.h>
+
+typedef __UINTPTR_TYPE__ uintptr_t;
+
+struct annotated {
+ int b;
+ char *c __attribute__ ((counted_by (b)));
+} *p_annotated;
+
+struct flex {
+ int b;
+ char *c;
+};
+
+struct nested_annotated {
+ struct {
+ union {
+ int b;
+ float f;
+ };
+ int n;
+ };
+ char *c __attribute__ ((counted_by (b)));
+} *p_nested_annotated;
+
+struct nested_flex {
+ struct {
+ union {
+ int b;
+ float f;
+ };
+ int n;
+ };
+ char *c;
+};
+
+void __attribute__((__noinline__)) setup (int normal_count, int attr_count)
+{
+ p_annotated
+ = (struct annotated *)malloc (sizeof (struct annotated));
+
+ p_annotated->c = (char *) malloc (sizeof (char) * attr_count);
+ p_annotated->b = attr_count;
+
+ p_nested_annotated
+ = (struct nested_annotated *)malloc (sizeof (struct nested_annotated));
+ p_nested_annotated->c = (char *) malloc (attr_count * sizeof (char));
+ p_nested_annotated->b = attr_count;
+
+ return;
+}
+
+void __attribute__((__noinline__)) test (char a, char b)
+{
+ if (__builtin_offsetof (struct annotated, c)
+ != __builtin_offsetof (struct flex, c))
+ abort ();
+ if (__builtin_offsetof (struct nested_annotated, c)
+ != __builtin_offsetof (struct nested_flex, c))
+ abort ();
+
+ if (__alignof (*p_annotated->c) != __alignof (char))
+ abort ();
+ if (__alignof (*p_nested_annotated->c) != __alignof (char))
+ abort ();
+
+ p_annotated->c[2] = a;
+ p_nested_annotated->c[3] = b;
+}
+
+int main(int argc, char *argv[])
+{
+ setup (10,10);
+ test ('A', 'B');
+ if (p_annotated->c[2] != 'A') abort ();
+ if (p_nested_annotated->c[3] != 'B') abort ();
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "ACCESS_WITH_SIZE" 4 "original" } } */
diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by.c b/gcc/testsuite/gcc.dg/pointer-counted-by.c
new file mode 100644
index 0000000..0f18828
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-counted-by.c
@@ -0,0 +1,111 @@
+/* Testing the correct usage of attribute counted_by for pointer field.
+ and also mixed pointer field and FMA field in the same structure. */
+/* { dg-do compile } */
+/* { dg-options "-O0" } */
+
+int size;
+int *x __attribute__ ((counted_by (size))); /* { dg-error "attribute is not allowed for a non-field declaration" } */
+
+struct pointer_array_0 {
+ int count;
+ int array __attribute__ ((counted_by (count))); /* { dg-error "attribute is not allowed for a non-array or non-pointer field" } */
+ int other;
+};
+
+int count;
+struct pointer_array_1 {
+ int other;
+ int *array_1 __attribute__ ((counted_by (count))); /* { dg-error "attribute is not a field declaration in the same structure as" } */
+ int array_fam[] __attribute__ ((counted_by (count))); /* { dg-error "attribute is not a field declaration in the same structure as" } */
+};
+
+struct pointer_array_2 {
+ float count1;
+ float count2;
+ int *array_2 __attribute__ ((counted_by (count1))); /* { dg-error "attribute is not a field declaration with an integer type" } */
+ int array_fam[] __attribute__ ((counted_by (count2))); /* { dg-error "attribute is not a field declaration with an integer type" } */
+};
+
+struct pointer_array_3 {
+ int count;
+ int *array_3 __attribute__ ((counted_by (count))) __attribute__ ((counted_by (count)));
+};
+
+struct pointer_array_4 {
+ int count1;
+ int count2;
+ int *array_4 __attribute__ ((counted_by (count1))) __attribute__ ((counted_by (count2))); /* { dg-error "conflicts with previous declaration" } */
+ float array_fam[] __attribute__ ((counted_by (count2))) __attribute__ ((counted_by (count1))); /* { dg-error "conflicts with previous declaration" } */
+};
+
+struct pointer_array_5 {
+ _Bool count;
+ int *array_5 __attribute__ ((counted_by (count)));
+};
+
+enum week {Mon, Tue, Wed};
+struct pointer_array_6 {
+ enum week days;
+ int *array_6 __attribute__ ((counted_by (days)));
+};
+
+struct pointer_array_7 {
+ int count;
+ void *array_7 __attribute__ ((counted_by (count))); /* { dg-error "attribute is not allowed for a pointer to void" } */
+};
+
+struct pointer_array_8 {
+ int count;
+ int (*fpr)(int,int) __attribute__ ((counted_by (count))); /* { dg-error "attribute is not allowed for a pointer to function" } */
+};
+
+struct item1 {
+ int a;
+ float b;
+};
+
+union item2 {
+ char *a;
+ int *b;
+};
+
+typedef struct item3 Item3;
+typedef union item4 Item4;
+
+struct item5 {
+ int a;
+ float b[];
+};
+
+/* Incomplete structure and union are allowed. */
+struct pointer_array_9 {
+ int count1;
+ int count2;
+ int count3;
+ struct item1 *array_1 __attribute__ ((counted_by (count1)));
+ union item2 *array_2 __attribute__ ((counted_by (count2)));
+ Item3 *array_3 __attribute__ ((counted_by (count3)));
+ Item4 *array_4 __attribute__ ((counted_by (count4)));
+ int count4;
+ int count5;
+ /* structure with flexible array member is not allowed. */
+ struct item5 *array_5 __attribute__ ((counted_by (count5))); /* { dg-error "attribute is not allowed for a pointer to structure or union with flexible array member" } */
+};
+
+struct mixed_array {
+ int count1;
+ float *array_1 __attribute__ ((counted_by (count1)));
+ float *array_2 __attribute__ ((counted_by (count1)));
+ int count2;
+ long *array_3 __attribute__ ((counted_by (count2)));
+ long array_4[] __attribute__ ((counted_by (count2)));
+};
+
+struct mixed_array_2 {
+ float *array_1 __attribute__ ((counted_by (count1)));
+ int count1;
+ float *array_2 __attribute__ ((counted_by (count1)));
+ long *array_3 __attribute__ ((counted_by (count2)));
+ int count2;
+ long array_4[] __attribute__ ((counted_by (count2)));
+};
diff --git a/gcc/testsuite/gcc.dg/pr109071.c b/gcc/testsuite/gcc.dg/pr109071.c
new file mode 100644
index 0000000..74b7b46
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr109071.c
@@ -0,0 +1,43 @@
+/* PR tree-optimization/109071 need more context for -Warray-bounds warnings
+ due to code duplication from jump threading. */
+/* { dg-options "-O2 -Wall -fdiagnostics-show-context=1" } */
+/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
+/* { dg-enable-nn-line-numbers "" } */
+
+extern void warn(void);
+static inline void assign(int val, int *regs, int index)
+{
+ if (index >= 4)
+ warn();
+ *regs = val;
+}
+struct nums {int vals[4];};
+
+void sparx5_set (int *ptr, struct nums *sg, int index)
+{
+ int *val = &sg->vals[index]; /* { dg-warning "is above array bounds" } */
+
+ assign(0, ptr, index);
+ assign(*val, ptr, index);
+}
+/* { dg-begin-multiline-output "" }
+ NN | int *val = &sg->vals[index];
+ | ~~~~~~~~^~~~~~~
+ 'sparx5_set': events 1-2
+ NN | if (index >= 4)
+ | ^
+ | |
+ | (1) when the condition is evaluated to true
+......
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ | ~~~~~~~~~~~~~~~
+ | |
+ | (2) warning happens here
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | struct nums {int vals[4];};
+ | ^~~~
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/gcc.dg/pr109071_1.c b/gcc/testsuite/gcc.dg/pr109071_1.c
new file mode 100644
index 0000000..592a998
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr109071_1.c
@@ -0,0 +1,36 @@
+/* PR tree-optimization/109071 need more context for -Warray-bounds warnings
+ due to code duplication from jump threading.
+ test case is from PR88771, which is a duplication of PR109071. */
+/* { dg-options "-O2 -fdiagnostics-show-context=1" } */
+/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
+/* { dg-enable-nn-line-numbers "" } */
+typedef struct {
+ int a;
+} * b;
+
+char *c, *x;
+int f;
+
+void d() {
+ b e;
+ char a = f + 1 ?: f;
+ __builtin_strncpy(c, x, f); /* { dg-warning "exceeds maximum object size" } */
+ if (a)
+ e->a = 0;
+}
+/* { dg-begin-multiline-output "" }
+ NN | __builtin_strncpy(c, x, f);
+ | ^~~~~~~~~~~~~~~~~~~~~~~~~~
+ 'd': events 1-2
+ NN | char a = f + 1 ?: f;
+ | ^
+ | |
+ | (1) when the condition is evaluated to false
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | __builtin_strncpy(c, x, f);
+ | ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ | |
+ | (2) warning happens here
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/gcc.dg/pr109071_10.c b/gcc/testsuite/gcc.dg/pr109071_10.c
new file mode 100644
index 0000000..1fe7edc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr109071_10.c
@@ -0,0 +1,85 @@
+/* PR tree-optimization/109071 need more context for -Warray-bounds warnings
+ due to compiler optimization. */
+/* { dg-options "-O2 -Warray-bounds -fdiagnostics-show-context=3" } */
+/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
+/* { dg-enable-nn-line-numbers "" } */
+#define MAX_LENGTH 10
+int a[MAX_LENGTH];
+
+void __attribute__ ((noinline)) foo (int i, bool is_dollar)
+{
+ if (i < MAX_LENGTH)
+ {
+ if (i == -1)
+ {
+ if (is_dollar)
+ __builtin_printf ("dollar");
+ else
+ __builtin_printf ("euro");
+ a[i] = -1; /* { dg-warning "is below array bounds of" } */
+ }
+ else
+ a[i] = i;
+ }
+ else
+ a[i] = i + 1; /* { dg-warning "is above array bounds of" } */
+}
+
+int main ()
+{
+ for (int i = 0; i < MAX_LENGTH; i++)
+ foo (i, true);
+ return 0;
+}
+
+/* { dg-begin-multiline-output "" }
+ NN | a[i] = i + 1;
+ | ~^~~
+ 'foo': events 1-2
+ NN | if (i < MAX_LENGTH)
+ | ^
+ | |
+ | (1) when the condition is evaluated to false
+......
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | a[i] = i + 1;
+ | ~~~~
+ | |
+ | (2) warning happens here
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | int a[MAX_LENGTH];
+ | ^
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | a[i] = -1;
+ | ~^~~
+ 'foo': events 1-3
+ NN | if (i < MAX_LENGTH)
+ | ~
+ | |
+ | (2) when the condition is evaluated to true
+ NN | {
+ NN | if (i == -1)
+ | ^
+ | |
+ | (1) when the condition is evaluated to true
+......
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | a[i] = -1;
+ | ~~~~
+ | |
+ | (3) warning happens here
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | int a[MAX_LENGTH];
+ | ^
+ { dg-end-multiline-output "" } */
+
diff --git a/gcc/testsuite/gcc.dg/pr109071_11.c b/gcc/testsuite/gcc.dg/pr109071_11.c
new file mode 100644
index 0000000..b9973bd
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr109071_11.c
@@ -0,0 +1,89 @@
+/* PR tree-optimization/109071 need more context for -Warray-bounds warnings
+ due to compiler optimization. */
+/* { dg-options "-O2 -Warray-bounds -fdiagnostics-show-context=3" } */
+/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
+/* { dg-enable-nn-line-numbers "" } */
+#define MAX_LENGTH 10
+int a[MAX_LENGTH];
+
+void __attribute__ ((noinline)) foo (int i, bool is_day, bool is_dollar)
+{
+ if (i < MAX_LENGTH)
+ {
+ if (is_day)
+ __builtin_printf ("day");
+ else
+ __builtin_printf ("night");
+ if (i == -1)
+ {
+ if (is_dollar)
+ __builtin_printf ("dollar");
+ else
+ __builtin_printf ("euro");
+ a[i] = -1; /* { dg-warning "is below array bounds of" } */
+ }
+ else
+ a[i] = i;
+ }
+ else
+ a[i] = i + 1; /* { dg-warning "is above array bounds of" } */
+}
+
+int main ()
+{
+ for (int i = 0; i < MAX_LENGTH; i++)
+ foo (i, false, true);
+ return 0;
+}
+
+/* { dg-begin-multiline-output "" }
+ NN | a[i] = i + 1;
+ | ~^~~
+ 'foo': events 1-2
+ NN | if (i < MAX_LENGTH)
+ | ^
+ | |
+ | (1) when the condition is evaluated to false
+......
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | a[i] = i + 1;
+ | ~~~~
+ | |
+ | (2) warning happens here
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | int a[MAX_LENGTH];
+ | ^
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | a[i] = -1;
+ | ~^~~
+ 'foo': events 1-3
+ NN | if (i < MAX_LENGTH)
+ | ~
+ | |
+ | (2) when the condition is evaluated to true
+......
+ NN | if (i == -1)
+ | ^
+ | |
+ | (1) when the condition is evaluated to true
+......
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | a[i] = -1;
+ | ~~~~
+ | |
+ | (3) warning happens here
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | int a[MAX_LENGTH];
+ | ^
+ { dg-end-multiline-output "" } */
+
diff --git a/gcc/testsuite/gcc.dg/pr109071_12.c b/gcc/testsuite/gcc.dg/pr109071_12.c
new file mode 100644
index 0000000..a77ae88
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr109071_12.c
@@ -0,0 +1,44 @@
+/* PR tree-optimization/109071 need more context for -Warray-bounds warnings
+ due to code duplication from jump threading.
+ to test the alias option -fdiagnostics-show-context. */
+/* { dg-options "-O2 -Wall -fdiagnostics-show-context" } */
+/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
+/* { dg-enable-nn-line-numbers "" } */
+
+extern void warn(void);
+static inline void assign(int val, int *regs, int index)
+{
+ if (index >= 4)
+ warn();
+ *regs = val;
+}
+struct nums {int vals[4];};
+
+void sparx5_set (int *ptr, struct nums *sg, int index)
+{
+ int *val = &sg->vals[index]; /* { dg-warning "is above array bounds" } */
+
+ assign(0, ptr, index);
+ assign(*val, ptr, index);
+}
+/* { dg-begin-multiline-output "" }
+ NN | int *val = &sg->vals[index];
+ | ~~~~~~~~^~~~~~~
+ 'sparx5_set': events 1-2
+ NN | if (index >= 4)
+ | ^
+ | |
+ | (1) when the condition is evaluated to true
+......
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ | ~~~~~~~~~~~~~~~
+ | |
+ | (2) warning happens here
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | struct nums {int vals[4];};
+ | ^~~~
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/gcc.dg/pr109071_2.c b/gcc/testsuite/gcc.dg/pr109071_2.c
new file mode 100644
index 0000000..549a8c4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr109071_2.c
@@ -0,0 +1,50 @@
+/* PR tree-optimization/109071 need more context for -Warray-bounds warnings
+ due to code duplication from jump threading.
+ test case is from PR85788, which is a duplication of PR109071. */
+/* { dg-options "-O2 -Warray-bounds -fdiagnostics-show-context=1" } */
+/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
+/* { dg-enable-nn-line-numbers "" } */
+int b=10;
+int *d = &b, *e;
+void a(void *k, long l) {
+ long f = __builtin_object_size(k, 0);
+ __builtin___memset_chk(k, b, l, f); /* { dg-warning "is out of the bounds" } */
+}
+typedef struct {
+ int g;
+ int h;
+ char i[8000 * 8];
+} j;
+static void make_str_raster(j *k) {
+ int *c = d;
+ for (; c; c = e)
+ k->g = k->h = 32767;
+
+ a(k->i, k->g / 8 * k->h);
+ for (; d;)
+ ;
+}
+j m;
+void n() { make_str_raster(&m); }
+/* { dg-begin-multiline-output "" }
+ NN | __builtin___memset_chk(k, b, l, f);
+ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ 'n': events 1-2
+ NN | __builtin___memset_chk(k, b, l, f);
+ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ | |
+ | (2) warning happens here
+......
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | for (; c; c = e)
+ | ^
+ | |
+ | (1) when the condition is evaluated to false
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | j m;
+ | ^
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/gcc.dg/pr109071_3.c b/gcc/testsuite/gcc.dg/pr109071_3.c
new file mode 100644
index 0000000..c7b86eb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr109071_3.c
@@ -0,0 +1,42 @@
+/* PR tree-optimization/109071 need more context for -Warray-bounds warnings
+ due to code duplication from jump threading.
+ test case is from PR108770, which is a duplication of PR109071. */
+/* { dg-options "-O2 -Warray-bounds -fdiagnostics-show-context=1" } */
+/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
+/* { dg-enable-nn-line-numbers "" } */
+extern void put(int i);
+int check_idx(int i) {
+ if (i > 1)
+ put(i);
+ return i;
+}
+const char *arr[] = {"A", 0};
+void init() {
+ int i = 0;
+ while (arr[check_idx(i)] != 0) { /* { dg-warning "is above array bounds of" } */
+ if (arr[check_idx(i)]) {}
+ i++;
+ }
+}
+/* { dg-begin-multiline-output "" }
+ NN | while (arr[check_idx(i)] != 0) {
+ | ~~~^~~~~~~~~~~~~~
+ 'init': events 1-2
+ NN | if (i > 1)
+ | ^
+ | |
+ | (1) when the condition is evaluated to true
+......
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | while (arr[check_idx(i)] != 0) {
+ | ~~~~~~~~~~~~~~~~~
+ | |
+ | (2) warning happens here
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | const char *arr[] = {"A", 0};
+ | ^~~
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/gcc.dg/pr109071_4.c b/gcc/testsuite/gcc.dg/pr109071_4.c
new file mode 100644
index 0000000..308249e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr109071_4.c
@@ -0,0 +1,41 @@
+/* PR tree-optimization/109071 need more context for -Warray-bounds warnings
+ due to code duplication from jump threading.
+ test case is from PR106762, which is a duplication of PR109071. */
+/* { dg-options "-O2 -Warray-bounds -fdiagnostics-show-context=1" } */
+/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
+/* { dg-enable-nn-line-numbers "" } */
+typedef long unsigned int size_t;
+
+struct obj_t { size_t field0; size_t field1; };
+struct obj_array_t { size_t objcnt; struct obj_t* objary; };
+
+extern void *memset (void *__s, int __c, size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__(1)));
+
+void bug(struct obj_array_t* ary)
+{
+ size_t idx = 0;
+ struct obj_t* obj;
+ if (idx < ary->objcnt)
+ obj = &ary->objary[idx];
+ else
+ obj = 0;
+ memset(&obj->field1, 0xff, sizeof(obj->field1)); /* { dg-warning "is out of the bounds" } */
+ obj->field0 = 0;
+}
+/* { dg-begin-multiline-output "" }
+ NN | memset(&obj->field1, 0xff, sizeof(obj->field1));
+ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ 'bug': events 1-2
+ NN | if (idx < ary->objcnt)
+ | ^
+ | |
+ | (1) when the condition is evaluated to false
+......
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | memset(&obj->field1, 0xff, sizeof(obj->field1));
+ | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ | |
+ | (2) warning happens here
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/gcc.dg/pr109071_5.c b/gcc/testsuite/gcc.dg/pr109071_5.c
new file mode 100644
index 0000000..466d518
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr109071_5.c
@@ -0,0 +1,33 @@
+/* PR tree-optimization/109071 need more context for -Warray-bounds warnings
+ due to code duplication from jump threading.
+ test case is from PR115274, which is a duplication of PR109071. */
+/* { dg-options "-O2 -Wstringop-overread -fdiagnostics-show-context=1" } */
+/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
+/* { dg-enable-nn-line-numbers "" } */
+#include <string.h>
+char *c;
+void a(long);
+int b(char *d) { return strlen(d); } /* { dg-warning "or more bytes from a region of size 0" } */
+void e() {
+ long f = 1;
+ f = b(c + f);
+ if (c == 0)
+ a(f);
+}
+/* { dg-begin-multiline-output "" }
+ NN | int b(char *d) { return strlen(d); }
+ | ^~~~~~~~~
+ 'e': events 1-2
+ NN | int b(char *d) { return strlen(d); }
+ | ~~~~~~~~~
+ | |
+ | (2) warning happens here
+......
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | if (c == 0)
+ | ^
+ | |
+ | (1) when the condition is evaluated to true
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/gcc.dg/pr109071_6.c b/gcc/testsuite/gcc.dg/pr109071_6.c
new file mode 100644
index 0000000..eddf15b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr109071_6.c
@@ -0,0 +1,49 @@
+/* PR tree-optimization/109071 need more context for -Warray-bounds warnings
+ due to code duplication from jump threading.
+ test case is from PR117179, which is a duplication of PR109071. */
+/* { dg-options "-O2 -Warray-bounds -fdiagnostics-show-context=1" } */
+/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
+/* { dg-enable-nn-line-numbers "" } */
+const char* commands[] = {"a", "b"};
+
+int setval_internal(int comind)
+{
+ if (comind > sizeof(commands)/sizeof(commands[0])) {
+ return 0;
+ }
+
+ return 1;
+}
+
+_Bool setval_internal_tilde(int comind, const char *com,
+ const char *val)
+{
+ int ret = setval_internal(comind);
+ if (commands[comind] == "b" && /* { dg-warning "is outside array bounds of" } */
+
+ ret)
+ return 1;
+ return 0;
+}
+/* { dg-begin-multiline-output "" }
+ NN | if (commands[comind] == "b" &&
+ | ~~~~~~~~^~~~~~~~
+ 'setval_internal_tilde': events 1-2
+ NN | if (comind > sizeof(commands)/sizeof(commands[0])) {
+ | ^
+ | |
+ | (1) when the condition is evaluated to true
+......
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | if (commands[comind] == "b" &&
+ | ~~~~~~~~~~~~~~~~
+ | |
+ | (2) warning happens here
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | const char* commands[] = {"a", "b"};
+ | ^~~~~~~~
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/gcc.dg/pr109071_7.c b/gcc/testsuite/gcc.dg/pr109071_7.c
new file mode 100644
index 0000000..a54a9f5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr109071_7.c
@@ -0,0 +1,44 @@
+/* PR tree-optimization/109071 need more context for -Warray-bounds warnings
+ due to compiler optimization. */
+/* { dg-options "-O2 -Warray-bounds -fdiagnostics-show-context=1" } */
+/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
+/* { dg-enable-nn-line-numbers "" } */
+#define MAX_LENGTH 10
+int a[MAX_LENGTH];
+
+void __attribute__ ((noinline)) foo (int i)
+{
+ if (i == 12)
+ a[i] = -1; /* { dg-warning "is above array bounds of" } */
+ else
+ a[i] = i;
+}
+
+int main ()
+{
+ for (int i = 0; i < MAX_LENGTH; i++)
+ foo (i);
+ return 0;
+}
+
+/* { dg-begin-multiline-output "" }
+ NN | a[i] = -1;
+ | ~^~~
+ 'foo': events 1-2
+ NN | if (i == 12)
+ | ^
+ | |
+ | (1) when the condition is evaluated to true
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | a[i] = -1;
+ | ~~~~
+ | |
+ | (2) warning happens here
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | int a[MAX_LENGTH];
+ | ^
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/gcc.dg/pr109071_8.c b/gcc/testsuite/gcc.dg/pr109071_8.c
new file mode 100644
index 0000000..13af458
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr109071_8.c
@@ -0,0 +1,51 @@
+/* PR tree-optimization/109071 need more context for -Warray-bounds warnings
+ due to compiler optimization. */
+/* { dg-options "-O2 -Warray-bounds -fdiagnostics-show-context=1" } */
+/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
+/* { dg-enable-nn-line-numbers "" } */
+#define MAX_LENGTH 10
+int a[MAX_LENGTH];
+
+void __attribute__ ((noinline)) foo (int i, bool is_dollar)
+{
+ if (i == -1)
+ {
+ if (is_dollar)
+ __builtin_printf ("dollar");
+ else
+ __builtin_printf ("euro");
+ a[i] = -1; /* { dg-warning "is below array bounds of" } */
+ }
+ else
+ a[i] = i;
+}
+
+int main ()
+{
+ for (int i = 0; i < MAX_LENGTH; i++)
+ foo (i, true);
+ return 0;
+}
+
+/* { dg-begin-multiline-output "" }
+ NN | a[i] = -1;
+ | ~^~~
+ 'foo': events 1-2
+ NN | if (i == -1)
+ | ^
+ | |
+ | (1) when the condition is evaluated to true
+......
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | a[i] = -1;
+ | ~~~~
+ | |
+ | (2) warning happens here
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | int a[MAX_LENGTH];
+ | ^
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/gcc.dg/pr109071_9.c b/gcc/testsuite/gcc.dg/pr109071_9.c
new file mode 100644
index 0000000..4892571
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr109071_9.c
@@ -0,0 +1,61 @@
+/* PR tree-optimization/109071 need more context for -Warray-bounds warnings
+ due to compiler optimization. */
+/* { dg-options "-O2 -Warray-bounds -fdiagnostics-show-context=1" } */
+/* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */
+/* { dg-enable-nn-line-numbers "" } */
+#define MAX_LENGTH 10
+int a[MAX_LENGTH];
+
+void __attribute__ ((noinline)) foo (int i, bool is_dollar,
+ bool is_hour, bool is_color)
+{
+ if (i == -1)
+ {
+ if (is_dollar)
+ __builtin_printf ("dollar");
+ else
+ __builtin_printf ("euro");
+ if (is_hour)
+ __builtin_printf ("hour");
+ else
+ {
+ if (is_color)
+ __builtin_printf ("color minute");
+ else
+ __builtin_printf ("non minute");
+ }
+ a[i] = -1; /* { dg-warning "is below array bounds of" } */
+ }
+ else
+ a[i] = i;
+}
+
+int main ()
+{
+ for (int i = 0; i < MAX_LENGTH; i++)
+ foo (i, true, false, true);
+ return 0;
+}
+
+/* { dg-begin-multiline-output "" }
+ NN | a[i] = -1;
+ | ~^~~
+ 'foo': events 1-2
+ NN | if (i == -1)
+ | ^
+ | |
+ | (1) when the condition is evaluated to true
+......
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | a[i] = -1;
+ | ~~~~
+ | |
+ | (2) warning happens here
+ { dg-end-multiline-output "" } */
+
+/* { dg-begin-multiline-output "" }
+ NN | int a[MAX_LENGTH];
+ | ^
+ { dg-end-multiline-output "" } */
diff --git a/gcc/testsuite/gcc.dg/pr117375.c b/gcc/testsuite/gcc.dg/pr117375.c
new file mode 100644
index 0000000..9679a03
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr117375.c
@@ -0,0 +1,13 @@
+/* PR middle-end/117375 ICE with -fdiagnostics-show-context=1 patch in sink pass. */
+/* { dg-do compile }
+ { dg-options "-O2 -Wall -fdiagnostics-show-context=1" } */
+
+int st, st_0;
+int nbFilledBytes, max;
+void ec_enc_shrink();
+void max_allowed() {
+ int nbAvailableBytes = nbFilledBytes;
+ if (st && st_0)
+ if (max < nbAvailableBytes)
+ ec_enc_shrink();
+}
diff --git a/gcc/testsuite/gcc.dg/pr118946-1.c b/gcc/testsuite/gcc.dg/pr118946-1.c
new file mode 100644
index 0000000..6cf2661
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr118946-1.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized -fdump-tree-forwprop1-details" } */
+
+/* PR tree-optimization/118946 */
+
+void f(char *a)
+{
+ char t[1024] = {};
+ __builtin_memcpy(a, t, 10);
+}
+
+/* We should be able to optimize the memcpy into a memset here. */
+/* { dg-final { scan-tree-dump-times "after previous" 1 "forwprop1"} } */
+/* { dg-final { scan-tree-dump-times "memset " 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-not "memcpy " "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/pr120929.c b/gcc/testsuite/gcc.dg/pr120929.c
new file mode 100644
index 0000000..8bb6d5c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr120929.c
@@ -0,0 +1,49 @@
+/* PR120929, pointee's size should not be propagated to pointer for
+ __builtin_dynamic_object_size. */
+
+/* { dg-do compile} */
+/* { dg-options "-O2" } */
+
+typedef __SIZE_TYPE__ size_t;
+
+extern void pin_pointer(void *);
+extern int some_value(void);
+
+struct magic_ {
+ char unused[9]; // at least 9
+};
+
+struct magic_map {
+ struct magic_ *magic;
+};
+
+static int
+coalesce_entries(struct magic_ **ma)
+{
+ size_t slen;
+
+ slen = sizeof (**ma);
+ *ma = __builtin_malloc (slen);
+
+ for (unsigned i = 0; i < 1; i++)
+ {
+ char b[1024] = {};
+ struct magic_ *ptr = *ma;
+ (void) __builtin___memcpy_chk (ptr, b, sizeof (*ptr), /* { dg-bogus "overflows the destination" } */
+ __builtin_dynamic_object_size (ptr, 0));
+ }
+ return 0;
+}
+
+struct magic_map *
+apprentice_load(void)
+{
+ char buf[128]; // did not shrink, but needs to be more than 100
+ struct magic_map *map2;
+
+ map2 = __builtin_malloc (sizeof (*map2));
+
+ pin_pointer(&buf);
+ coalesce_entries(&map2->magic);
+ pin_pointer(map2);
+}
diff --git a/gcc/testsuite/gcc.dg/pr121619.c b/gcc/testsuite/gcc.dg/pr121619.c
new file mode 100644
index 0000000..a63896d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr121619.c
@@ -0,0 +1,33 @@
+/* { dg-do run } */
+/* { dg-options "-O3 -fno-gcse -fno-tree-ter -fno-guess-branch-probability -fno-forward-propagate" } */
+
+int printf(const char *, ...);
+long a, c, d;
+char b;
+int main() {
+f : {
+ short g = 100;
+ int h = 1;
+ while (1) {
+ char i = 0;
+ if (a)
+ i = h = -b;
+ short j = g;
+ c = h ^ g;
+ g = ~(-h / c + 1);
+ if (b > 6) {
+ a = g && -1;
+ goto f;
+ }
+ if (j < 100)
+ printf("%ld\n", d);
+ if (g - 1)
+ break;
+ b = i;
+ }
+ int k = 2L % g;
+ if (k)
+ goto f;
+ }
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/pr89828.c b/gcc/testsuite/gcc.dg/pr89828.c
new file mode 100644
index 0000000..d41fbae
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr89828.c
@@ -0,0 +1,49 @@
+/* { dg-do compile { target rx-*-* } } */
+/* { dg-options "-O2 -g -fno-omit-frame-pointer" } */
+struct baz;
+struct foo {
+ struct baz *c;
+ unsigned int flags;
+};
+struct bar {
+ const struct bar *b;
+ void (*func)(struct foo *a, struct baz *c, int flags);
+};
+struct baz {
+ int flag;
+ const struct bar *b;
+};
+static inline
+__attribute__((always_inline))
+__attribute__((no_instrument_function)) void inline1(struct foo *a)
+{
+ a->flags |= 1;
+}
+static inline
+__attribute__((always_inline))
+__attribute__((no_instrument_function)) int inline2(struct baz *c)
+{
+ return c->flag == 1;
+}
+extern const struct bar _bar;
+extern void func(struct foo *a);
+void pr89828(struct foo *a, struct baz *c, int flags)
+{
+ const struct bar *b;
+
+ if (c->b == a->c->b) {
+ a->c->b->func(a, c, flags);
+ } else {
+ for (b = (&_bar); b; b = b->b) {
+ if (b == a->c->b)
+ break;
+ if (b == c->b) {
+ func(a);
+ break;
+ }
+ }
+ }
+
+ if (inline2(a->c))
+ inline1(a);
+}
diff --git a/gcc/testsuite/gcc.dg/pr94589-2.c b/gcc/testsuite/gcc.dg/pr94589-2.c
index 9481b76..b20cccd 100644
--- a/gcc/testsuite/gcc.dg/pr94589-2.c
+++ b/gcc/testsuite/gcc.dg/pr94589-2.c
@@ -1,35 +1,63 @@
/* PR tree-optimization/94589 */
/* { dg-do compile } */
/* { dg-options "-O2 -g0 -ffast-math -fdump-tree-optimized" } */
-/* { dg-final { scan-tree-dump-times "\[ij]_\[0-9]+\\(D\\) (?:<|<=|==|!=|>|>=) \[ij]_\[0-9]+\\(D\\)" 14 "optimized" } } */
-/* { dg-final { scan-tree-dump-times "i_\[0-9]+\\(D\\) (?:<|<=|==|!=|>|>=) 5\\.0" 14 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "\[ij]_\[0-9]+\\(D\\) (?:<|<=|==|!=|>|>=) \[ij]_\[0-9]+\\(D\\)" 28 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "i_\[0-9]+\\(D\\) (?:<|<=|==|!=|>|>=) 5\\.0" 28 "optimized" } } */
#define A __attribute__((noipa))
-A int f1 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c == 0; }
-A int f2 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c != 0; }
-A int f3 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c > 0; }
-A int f4 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c < 0; }
-A int f5 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c >= 0; }
-A int f6 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c <= 0; }
-A int f7 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c == -1; }
-A int f8 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c != -1; }
-A int f9 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c > -1; }
-A int f10 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c <= -1; }
-A int f11 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c == 1; }
-A int f12 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c != 1; }
-A int f13 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c < 1; }
-A int f14 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c >= 1; }
-A int f15 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c == 0; }
-A int f16 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c != 0; }
-A int f17 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c > 0; }
-A int f18 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c < 0; }
-A int f19 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c >= 0; }
-A int f20 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c <= 0; }
-A int f21 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c == -1; }
-A int f22 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c != -1; }
-A int f23 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c > -1; }
-A int f24 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c <= -1; }
-A int f25 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c == 1; }
-A int f26 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c != 1; }
-A int f27 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c < 1; }
-A int f28 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c >= 1; }
+A int f1 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c == 0; }
+A int f2 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c != 0; }
+A int f3 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c > 0; }
+A int f4 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c < 0; }
+A int f5 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c >= 0; }
+A int f6 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c <= 0; }
+A int f7 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c == -1; }
+A int f8 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c != -1; }
+A int f9 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c > -1; }
+A int f10 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c <= -1; }
+A int f11 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c == 1; }
+A int f12 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c != 1; }
+A int f13 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c < 1; }
+A int f14 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c >= 1; }
+A int f15 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c == 0; }
+A int f16 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c != 0; }
+A int f17 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c > 0; }
+A int f18 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c < 0; }
+A int f19 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c >= 0; }
+A int f20 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c <= 0; }
+A int f21 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c == -1; }
+A int f22 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c != -1; }
+A int f23 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c > -1; }
+A int f24 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c <= -1; }
+A int f25 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c == 1; }
+A int f26 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c != 1; }
+A int f27 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c < 1; }
+A int f28 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c >= 1; }
+A int f29 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f == 0; }
+A signed char f30 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f != 0; }
+A signed char f31 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f < 0; }
+A signed char f32 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f > 0; }
+A signed char f33 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f <= 0; }
+A signed char f34 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f >= 0; }
+A signed char f35 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f == 1; }
+A signed char f36 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f != 1; }
+A signed char f37 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f < 1; }
+A signed char f38 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f >= 1; }
+A signed char f39 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f == -1; }
+A signed char f40 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f != -1; }
+A signed char f41 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f > -1; }
+A signed char f42 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f <= -1; }
+A signed char f43 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f == 0; }
+A signed char f44 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f != 0; }
+A signed char f45 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f < 0; }
+A signed char f46 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f > 0; }
+A signed char f47 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f <= 0; }
+A signed char f48 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f >= 0; }
+A signed char f49 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f == 1; }
+A signed char f50 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f != 1; }
+A signed char f51 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f < 1; }
+A signed char f52 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f >= 1; }
+A signed char f53 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f == -1; }
+A signed char f54 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f != -1; }
+A signed char f55 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f > -1; }
+A signed char f56 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f <= -1; }
diff --git a/gcc/testsuite/gcc.dg/pr94589-4.c b/gcc/testsuite/gcc.dg/pr94589-4.c
index b2557fb..f277b6c 100644
--- a/gcc/testsuite/gcc.dg/pr94589-4.c
+++ b/gcc/testsuite/gcc.dg/pr94589-4.c
@@ -93,5 +93,89 @@ main ()
D (f28, 4.0, 0);
D (f28, 5.0, 0);
D (f28, 6.0, 1);
+ C (f29, 7.0, 8.0, 0);
+ C (f29, 8.0, 8.0, 1);
+ C (f29, 9.0, 8.0, 0);
+ C (f30, 7.0, 8.0, 1);
+ C (f30, 8.0, 8.0, 0);
+ C (f30, 9.0, 8.0, 1);
+ C (f31, 7.0, 8.0, 0);
+ C (f31, 8.0, 8.0, 0);
+ C (f31, 9.0, 8.0, 1);
+ C (f32, 7.0, 8.0, 1);
+ C (f32, 8.0, 8.0, 0);
+ C (f32, 9.0, 8.0, 0);
+ C (f33, 7.0, 8.0, 0);
+ C (f33, 8.0, 8.0, 1);
+ C (f33, 9.0, 8.0, 1);
+ C (f34, 7.0, 8.0, 1);
+ C (f34, 8.0, 8.0, 1);
+ C (f34, 9.0, 8.0, 0);
+ C (f35, 7.0, 8.0, 1);
+ C (f35, 8.0, 8.0, 0);
+ C (f35, 9.0, 8.0, 0);
+ C (f36, 7.0, 8.0, 0);
+ C (f36, 8.0, 8.0, 1);
+ C (f36, 9.0, 8.0, 1);
+ C (f37, 7.0, 8.0, 0);
+ C (f37, 8.0, 8.0, 1);
+ C (f37, 9.0, 8.0, 1);
+ C (f38, 7.0, 8.0, 1);
+ C (f38, 8.0, 8.0, 0);
+ C (f38, 9.0, 8.0, 0);
+ C (f39, 7.0, 8.0, 0);
+ C (f39, 8.0, 8.0, 0);
+ C (f39, 9.0, 8.0, 1);
+ C (f40, 7.0, 8.0, 1);
+ C (f40, 8.0, 8.0, 1);
+ C (f40, 9.0, 8.0, 0);
+ C (f41, 7.0, 8.0, 1);
+ C (f41, 8.0, 8.0, 1);
+ C (f41, 9.0, 8.0, 0);
+ C (f42, 7.0, 8.0, 0);
+ C (f42, 8.0, 8.0, 0);
+ C (f42, 9.0, 8.0, 1);
+ D (f43, 4.0, 0);
+ D (f43, 5.0, 1);
+ D (f43, 6.0, 0);
+ D (f44, 4.0, 1);
+ D (f44, 5.0, 0);
+ D (f44, 6.0, 1);
+ D (f45, 4.0, 0);
+ D (f45, 5.0, 0);
+ D (f45, 6.0, 1);
+ D (f46, 4.0, 1);
+ D (f46, 5.0, 0);
+ D (f46, 6.0, 0);
+ D (f47, 4.0, 0);
+ D (f47, 5.0, 1);
+ D (f47, 6.0, 1);
+ D (f48, 4.0, 1);
+ D (f48, 5.0, 1);
+ D (f48, 6.0, 0);
+ D (f49, 4.0, 1);
+ D (f49, 5.0, 0);
+ D (f49, 6.0, 0);
+ D (f50, 4.0, 0);
+ D (f50, 5.0, 1);
+ D (f50, 6.0, 1);
+ D (f51, 4.0, 0);
+ D (f51, 5.0, 1);
+ D (f51, 6.0, 1);
+ D (f52, 4.0, 1);
+ D (f52, 5.0, 0);
+ D (f52, 6.0, 0);
+ D (f53, 4.0, 0);
+ D (f53, 5.0, 0);
+ D (f53, 6.0, 1);
+ D (f54, 4.0, 1);
+ D (f54, 5.0, 1);
+ D (f54, 6.0, 0);
+ D (f55, 4.0, 1);
+ D (f55, 5.0, 1);
+ D (f55, 6.0, 0);
+ D (f56, 4.0, 0);
+ D (f56, 5.0, 0);
+ D (f56, 6.0, 1);
return 0;
}
diff --git a/gcc/testsuite/gcc.dg/pr94589-5.c b/gcc/testsuite/gcc.dg/pr94589-5.c
index 8777fa4..65dfd05 100644
--- a/gcc/testsuite/gcc.dg/pr94589-5.c
+++ b/gcc/testsuite/gcc.dg/pr94589-5.c
@@ -1,35 +1,55 @@
/* PR tree-optimization/94589 */
/* { dg-do compile { target inf } } */
/* { dg-options "-O2 -g0 -fdump-tree-optimized" } */
-/* { dg-final { scan-tree-dump-times "\[ij]_\[0-9]+\\(D\\) (?:<|<=|>|>=) \[ij]_\[0-9]+\\(D\\)" 14 "optimized" } } */
-/* { dg-final { scan-tree-dump-times "i_\[0-9]+\\(D\\) (?:<|<=|>|>=) 5\\.0" 14 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "\[ij]_\[0-9]+\\(D\\) (?:<|<=|>|>=) \[ij]_\[0-9]+\\(D\\)" 24 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "i_\[0-9]+\\(D\\) (?:<|<=|>|>=) 5\\.0" 24 "optimized" } } */
#define A __attribute__((noipa))
-A int f3 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c > 0; }
-A int f4 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c < 0; }
-A int f5 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c >= 0; }
-A int f6 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c <= 0; }
-A int f7 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c == -1; }
-A int f8 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c != -1; }
-A int f9 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c > -1; }
-A int f10 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c <= -1; }
-A int f11 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c == 1; }
-A int f12 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c != 1; }
-A int f13 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c < 1; }
-A int f14 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c >= 1; }
-A int f17 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c > 0; }
-A int f18 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c < 0; }
-A int f19 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c >= 0; }
-A int f20 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c <= 0; }
-A int f21 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c == -1; }
-A int f22 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c != -1; }
-A int f23 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c > -1; }
-A int f24 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c <= -1; }
-A int f25 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c == 1; }
-A int f26 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c != 1; }
-A int f27 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c < 1; }
-A int f28 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c >= 1; }
-A int f29 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return (c & ~1) == 0; }
-A int f30 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return (c & ~1) != 0; }
-A int f31 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return (c & ~1) == 0; }
-A int f32 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return (c & ~1) != 0; }
+A int f3 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c > 0; }
+A int f4 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c < 0; }
+A int f5 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c >= 0; }
+A int f6 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c <= 0; }
+A int f7 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c == -1; }
+A int f8 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c != -1; }
+A int f9 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c > -1; }
+A int f10 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c <= -1; }
+A int f11 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c == 1; }
+A int f12 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c != 1; }
+A int f13 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c < 1; }
+A int f14 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c >= 1; }
+A int f17 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c > 0; }
+A int f18 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c < 0; }
+A int f19 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c >= 0; }
+A int f20 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c <= 0; }
+A int f21 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c == -1; }
+A int f22 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c != -1; }
+A int f23 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c > -1; }
+A int f24 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c <= -1; }
+A int f25 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c == 1; }
+A int f26 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c != 1; }
+A int f27 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c < 1; }
+A int f28 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c >= 1; }
+A signed char f31 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f < 0; }
+A signed char f32 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f > 0; }
+A signed char f33 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f <= 0; }
+A signed char f34 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f >= 0; }
+A signed char f35 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f == 1; }
+A signed char f36 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f != 1; }
+A signed char f37 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f < 1; }
+A signed char f38 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f >= 1; }
+A signed char f39 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f == -1; }
+A signed char f40 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f != -1; }
+A signed char f41 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f > -1; }
+A signed char f42 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f <= -1; }
+A signed char f45 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f < 0; }
+A signed char f46 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f > 0; }
+A signed char f47 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f <= 0; }
+A signed char f48 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f >= 0; }
+A signed char f49 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f == 1; }
+A signed char f50 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f != 1; }
+A signed char f51 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f < 1; }
+A signed char f52 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f >= 1; }
+A signed char f53 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f == -1; }
+A signed char f54 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f != -1; }
+A signed char f55 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f > -1; }
+A signed char f56 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f <= -1; }
diff --git a/gcc/testsuite/gcc.dg/pr94589-6.c b/gcc/testsuite/gcc.dg/pr94589-6.c
index 2014c1c..3131ab4 100644
--- a/gcc/testsuite/gcc.dg/pr94589-6.c
+++ b/gcc/testsuite/gcc.dg/pr94589-6.c
@@ -3,13 +3,19 @@
#include "pr94589-5.c"
-A int f1 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c == 0; }
-A int f2 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = 2; return c != 0; }
-A int f15 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c == 0; }
-A int f16 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = 2; return c != 0; }
+A int f1 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c == 0; }
+A int f2 (double i, double j) { int c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; return c != 0; }
+A int f15 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c == 0; }
+A int f16 (double i) { int c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; return c != 0; }
+A int f29 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f == 0; }
+A int f30 (double i, double j) { signed char c; if (i == j) c = 0; else if (i < j) c = -1; else if (i > j) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f != 0; }
+A int f43 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f == 0; }
+A int f44 (double i) { signed char c; if (i == 5.0) c = 0; else if (i < 5.0) c = -1; else if (i > 5.0) c = 1; else c = -128; unsigned char d = c; unsigned char e = -d; signed char f = e; return f != 0; }
-#define C(fn, i, j, r) if (fn (i, j) != r) __builtin_abort ()
-#define D(fn, i, r) if (fn (i) != r) __builtin_abort ()
+//#define C(fn, i, j, r) if (fn (i, j) != r) __builtin_abort ()
+//#define D(fn, i, r) if (fn (i) != r) __builtin_abort ()
+#define C(fn, i, j, r) if (fn (i, j) != r) __builtin_printf ("%d\n", __LINE__)
+#define D(fn, i, r) if (fn (i) != r) __builtin_printf ("%d\n", __LINE__)
int
main ()
@@ -25,19 +31,19 @@ main ()
C (f3, 7.0, 8.0, 0);
C (f3, 8.0, 8.0, 0);
C (f3, 9.0, 8.0, 1);
- C (f3, __builtin_nan (""), 8.0, 1);
+ C (f3, __builtin_nan (""), 8.0, 0);
C (f4, 7.0, 8.0, 1);
C (f4, 8.0, 8.0, 0);
C (f4, 9.0, 8.0, 0);
- C (f4, __builtin_nan (""), 8.0, 0);
+ C (f4, __builtin_nan (""), 8.0, 1);
C (f5, 7.0, 8.0, 0);
C (f5, 8.0, 8.0, 1);
C (f5, 9.0, 8.0, 1);
- C (f5, __builtin_nan (""), 8.0, 1);
+ C (f5, __builtin_nan (""), 8.0, 0);
C (f6, 7.0, 8.0, 1);
C (f6, 8.0, 8.0, 1);
C (f6, 9.0, 8.0, 0);
- C (f6, __builtin_nan (""), 8.0, 0);
+ C (f6, __builtin_nan (""), 8.0, 1);
C (f7, 7.0, 8.0, 1);
C (f7, 8.0, 8.0, 0);
C (f7, 9.0, 8.0, 0);
@@ -49,11 +55,11 @@ main ()
C (f9, 7.0, 8.0, 0);
C (f9, 8.0, 8.0, 1);
C (f9, 9.0, 8.0, 1);
- C (f9, __builtin_nan (""), 8.0, 1);
+ C (f9, __builtin_nan (""), 8.0, 0);
C (f10, 7.0, 8.0, 1);
C (f10, 8.0, 8.0, 0);
C (f10, 9.0, 8.0, 0);
- C (f10, __builtin_nan (""), 8.0, 0);
+ C (f10, __builtin_nan (""), 8.0, 1);
C (f11, 7.0, 8.0, 0);
C (f11, 8.0, 8.0, 0);
C (f11, 9.0, 8.0, 1);
@@ -65,11 +71,11 @@ main ()
C (f13, 7.0, 8.0, 1);
C (f13, 8.0, 8.0, 1);
C (f13, 9.0, 8.0, 0);
- C (f13, __builtin_nan (""), 8.0, 0);
+ C (f13, __builtin_nan (""), 8.0, 1);
C (f14, 7.0, 8.0, 0);
C (f14, 8.0, 8.0, 0);
C (f14, 9.0, 8.0, 1);
- C (f14, __builtin_nan (""), 8.0, 1);
+ C (f14, __builtin_nan (""), 8.0, 0);
D (f15, 4.0, 0);
D (f15, 5.0, 1);
D (f15, 6.0, 0);
@@ -81,19 +87,19 @@ main ()
D (f17, 4.0, 0);
D (f17, 5.0, 0);
D (f17, 6.0, 1);
- D (f17, __builtin_nan (""), 1);
+ D (f17, __builtin_nan (""), 0);
D (f18, 4.0, 1);
D (f18, 5.0, 0);
D (f18, 6.0, 0);
- D (f18, __builtin_nan (""), 0);
+ D (f18, __builtin_nan (""), 1);
D (f19, 4.0, 0);
D (f19, 5.0, 1);
D (f19, 6.0, 1);
- D (f19, __builtin_nan (""), 1);
+ D (f19, __builtin_nan (""), 0);
D (f20, 4.0, 1);
D (f20, 5.0, 1);
D (f20, 6.0, 0);
- D (f20, __builtin_nan (""), 0);
+ D (f20, __builtin_nan (""), 1);
D (f21, 4.0, 1);
D (f21, 5.0, 0);
D (f21, 6.0, 0);
@@ -105,11 +111,11 @@ main ()
D (f23, 4.0, 0);
D (f23, 5.0, 1);
D (f23, 6.0, 1);
- D (f23, __builtin_nan (""), 1);
+ D (f23, __builtin_nan (""), 0);
D (f24, 4.0, 1);
D (f24, 5.0, 0);
D (f24, 6.0, 0);
- D (f24, __builtin_nan (""), 0);
+ D (f24, __builtin_nan (""), 1);
D (f25, 4.0, 0);
D (f25, 5.0, 0);
D (f25, 6.0, 1);
@@ -121,26 +127,122 @@ main ()
D (f27, 4.0, 1);
D (f27, 5.0, 1);
D (f27, 6.0, 0);
- D (f27, __builtin_nan (""), 0);
+ D (f27, __builtin_nan (""), 1);
D (f28, 4.0, 0);
D (f28, 5.0, 0);
D (f28, 6.0, 1);
- D (f28, __builtin_nan (""), 1);
+ D (f28, __builtin_nan (""), 0);
C (f29, 7.0, 8.0, 0);
C (f29, 8.0, 8.0, 1);
- C (f29, 9.0, 8.0, 1);
+ C (f29, 9.0, 8.0, 0);
C (f29, __builtin_nan (""), 8.0, 0);
C (f30, 7.0, 8.0, 1);
C (f30, 8.0, 8.0, 0);
- C (f30, 9.0, 8.0, 0);
+ C (f30, 9.0, 8.0, 1);
C (f30, __builtin_nan (""), 8.0, 1);
- D (f31, 4.0, 0);
- D (f31, 5.0, 1);
- D (f31, 6.0, 1);
- D (f31, __builtin_nan (""), 0);
- D (f32, 4.0, 1);
- D (f32, 5.0, 0);
- D (f32, 6.0, 0);
- D (f32, __builtin_nan (""), 1);
+ C (f31, 7.0, 8.0, 0);
+ C (f31, 8.0, 8.0, 0);
+ C (f31, 9.0, 8.0, 1);
+ C (f31, __builtin_nan (""), 8.0, 1);
+ C (f32, 7.0, 8.0, 1);
+ C (f32, 8.0, 8.0, 0);
+ C (f32, 9.0, 8.0, 0);
+ C (f32, __builtin_nan (""), 8.0, 0);
+ C (f33, 7.0, 8.0, 0);
+ C (f33, 8.0, 8.0, 1);
+ C (f33, 9.0, 8.0, 1);
+ C (f33, __builtin_nan (""), 8.0, 1);
+ C (f34, 7.0, 8.0, 1);
+ C (f34, 8.0, 8.0, 1);
+ C (f34, 9.0, 8.0, 0);
+ C (f34, __builtin_nan (""), 8.0, 0);
+ C (f35, 7.0, 8.0, 1);
+ C (f35, 8.0, 8.0, 0);
+ C (f35, 9.0, 8.0, 0);
+ C (f35, __builtin_nan (""), 8.0, 0);
+ C (f36, 7.0, 8.0, 0);
+ C (f36, 8.0, 8.0, 1);
+ C (f36, 9.0, 8.0, 1);
+ C (f36, __builtin_nan (""), 8.0, 1);
+ C (f37, 7.0, 8.0, 0);
+ C (f37, 8.0, 8.0, 1);
+ C (f37, 9.0, 8.0, 1);
+ C (f37, __builtin_nan (""), 8.0, 1);
+ C (f38, 7.0, 8.0, 1);
+ C (f38, 8.0, 8.0, 0);
+ C (f38, 9.0, 8.0, 0);
+ C (f38, __builtin_nan (""), 8.0, 0);
+ C (f39, 7.0, 8.0, 0);
+ C (f39, 8.0, 8.0, 0);
+ C (f39, 9.0, 8.0, 1);
+ C (f39, __builtin_nan (""), 8.0, 0);
+ C (f40, 7.0, 8.0, 1);
+ C (f40, 8.0, 8.0, 1);
+ C (f40, 9.0, 8.0, 0);
+ C (f40, __builtin_nan (""), 8.0, 1);
+ C (f41, 7.0, 8.0, 1);
+ C (f41, 8.0, 8.0, 1);
+ C (f41, 9.0, 8.0, 0);
+ C (f41, __builtin_nan (""), 8.0, 0);
+ C (f42, 7.0, 8.0, 0);
+ C (f42, 8.0, 8.0, 0);
+ C (f42, 9.0, 8.0, 1);
+ C (f42, __builtin_nan (""), 8.0, 1);
+ D (f43, 4.0, 0);
+ D (f43, 5.0, 1);
+ D (f43, 6.0, 0);
+ D (f43, __builtin_nan (""), 0);
+ D (f44, 4.0, 1);
+ D (f44, 5.0, 0);
+ D (f44, 6.0, 1);
+ D (f44, __builtin_nan (""), 1);
+ D (f45, 4.0, 0);
+ D (f45, 5.0, 0);
+ D (f45, 6.0, 1);
+ D (f45, __builtin_nan (""), 1);
+ D (f46, 4.0, 1);
+ D (f46, 5.0, 0);
+ D (f46, 6.0, 0);
+ D (f46, __builtin_nan (""), 0);
+ D (f47, 4.0, 0);
+ D (f47, 5.0, 1);
+ D (f47, 6.0, 1);
+ D (f47, __builtin_nan (""), 1);
+ D (f48, 4.0, 1);
+ D (f48, 5.0, 1);
+ D (f48, 6.0, 0);
+ D (f48, __builtin_nan (""), 0);
+ D (f49, 4.0, 1);
+ D (f49, 5.0, 0);
+ D (f49, 6.0, 0);
+ D (f49, __builtin_nan (""), 0);
+ D (f50, 4.0, 0);
+ D (f50, 5.0, 1);
+ D (f50, 6.0, 1);
+ D (f50, __builtin_nan (""), 1);
+ D (f51, 4.0, 0);
+ D (f51, 5.0, 1);
+ D (f51, 6.0, 1);
+ D (f51, __builtin_nan (""), 1);
+ D (f52, 4.0, 1);
+ D (f52, 5.0, 0);
+ D (f52, 6.0, 0);
+ D (f52, __builtin_nan (""), 0);
+ D (f53, 4.0, 0);
+ D (f53, 5.0, 0);
+ D (f53, 6.0, 1);
+ D (f53, __builtin_nan (""), 0);
+ D (f54, 4.0, 1);
+ D (f54, 5.0, 1);
+ D (f54, 6.0, 0);
+ D (f54, __builtin_nan (""), 1);
+ D (f55, 4.0, 1);
+ D (f55, 5.0, 1);
+ D (f55, 6.0, 0);
+ D (f55, __builtin_nan (""), 0);
+ D (f56, 4.0, 0);
+ D (f56, 5.0, 0);
+ D (f56, 6.0, 1);
+ D (f56, __builtin_nan (""), 1);
return 0;
}
diff --git a/gcc/testsuite/gcc.dg/torture/copy-prop-aggr-zero-1.c b/gcc/testsuite/gcc.dg/torture/copy-prop-aggr-zero-1.c
new file mode 100644
index 0000000..5c457b9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/copy-prop-aggr-zero-1.c
@@ -0,0 +1,28 @@
+/* { dg-do run } */
+
+/* Make sure a bit-field store of 0 cause the whole assignment become 0. */
+
+struct s1
+{
+ unsigned char c:1;
+ unsigned char d:7;
+};
+
+__attribute__((noinline))
+struct s1 f(struct s1 a)
+{
+ a.c = 0;
+ struct s1 t = a;
+ return t;
+}
+
+int main()
+{
+ struct s1 a = {1, 2};
+ struct s1 b = f(a);
+ if (b.c != 0)
+ __builtin_abort();
+ if (b.d != 2)
+ __builtin_abort();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/copy-prop-aggr-zero-2.c b/gcc/testsuite/gcc.dg/torture/copy-prop-aggr-zero-2.c
new file mode 100644
index 0000000..f1da161
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/copy-prop-aggr-zero-2.c
@@ -0,0 +1,28 @@
+/* { dg-do run } */
+
+/* Make sure a bit-field store of 0 cause the whole assignment become 0. */
+
+struct s1
+{
+ unsigned char d:7;
+ unsigned char c:1;
+};
+
+__attribute__((noinline))
+struct s1 f(struct s1 a)
+{
+ a.c = 0;
+ struct s1 t = a;
+ return t;
+}
+
+int main()
+{
+ struct s1 a = {2, 1};
+ struct s1 b = f(a);
+ if (b.c != 0)
+ __builtin_abort();
+ if (b.d != 2)
+ __builtin_abort();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/darwin-cfstring-3.c b/gcc/testsuite/gcc.dg/torture/darwin-cfstring-3.c
index ee4b385..4be3a25 100644
--- a/gcc/testsuite/gcc.dg/torture/darwin-cfstring-3.c
+++ b/gcc/testsuite/gcc.dg/torture/darwin-cfstring-3.c
@@ -24,7 +24,7 @@ void foo(void) {
s0 = s1;
}
-/* { dg-final { scan-assembler "\\.long\[ \\t\]+___CFConstantStringClassReference\n\[ \\t\]*\\.long\[ \\t\]+1992\n\[ \\t\]*\\.long\[ \\t\]+\[lL\]C.*\n\[ \\t\]*\\.long\[ \\t\]+4\n" { target { *-*-darwin* && { ! lp64 } } } } } */
-/* { dg-final { scan-assembler "\\.long\[ \\t\]+___CFConstantStringClassReference\n\[ \\t\]*\\.long\[ \\t\]+1992\n\[ \\t\]*\\.long\[ \\t\]+\[lL\]C.*\n\[ \\t\]*\\.long\[ \\t\]+10\n" { target { *-*-darwin* && { ! lp64 } } } } } */
-/* { dg-final { scan-assembler ".quad\t___CFConstantStringClassReference\n\t.long\t1992\n\t.space 4\n\t.quad\t.*\n\t.quad\t4\n" { target { *-*-darwin* && { lp64 } } } } } */
-/* { dg-final { scan-assembler ".quad\t___CFConstantStringClassReference\n\t.long\t1992\n\t.space 4\n\t.quad\t.*\n\t.quad\t10\n" { target { *-*-darwin* && { lp64 } } } } } */
+/* { dg-final { scan-assembler "\\.long\[ \\t\]+___CFConstantStringClassReference\n\[ \\t\]*\\.long\[ \\t\]+1992\n\[ \\t\]*\\.long\[ \\t\]+L\.str\..*\n\[ \\t\]*\\.long\[ \\t\]+4\n" { target { *-*-darwin* && { ! lp64 } } } } } */
+/* { dg-final { scan-assembler "\\.long\[ \\t\]+___CFConstantStringClassReference\n\[ \\t\]*\\.long\[ \\t\]+1992\n\[ \\t\]*\\.long\[ \\t\]+L\.str\..*\n\[ \\t\]*\\.long\[ \\t\]+10\n" { target { *-*-darwin* && { ! lp64 } } } } } */
+/* { dg-final { scan-assembler ".quad\t___CFConstantStringClassReference\n\t.long\t1992\n\t.space 4\n\t.quad\tL\.str\..*\n\t.quad\t4\n" { target { *-*-darwin* && { lp64 } } } } } */
+/* { dg-final { scan-assembler ".quad\t___CFConstantStringClassReference\n\t.long\t1992\n\t.space 4\n\t.quad\tL\.str\..*\n\t.quad\t10\n" { target { *-*-darwin* && { lp64 } } } } } */
diff --git a/gcc/testsuite/gcc.dg/torture/hardbool-ai.c b/gcc/testsuite/gcc.dg/torture/hardbool-ai.c
index 97569a6..af4e0e1 100644
--- a/gcc/testsuite/gcc.dg/torture/hardbool-ai.c
+++ b/gcc/testsuite/gcc.dg/torture/hardbool-ai.c
@@ -1,4 +1,5 @@
/* { dg-do run } */
+/* { dg-require-effective-target sync_int_long } */
#define basetype _Atomic int
diff --git a/gcc/testsuite/gcc.dg/torture/malloc-1.c b/gcc/testsuite/gcc.dg/torture/malloc-1.c
new file mode 100644
index 0000000..ba24153
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/malloc-1.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* PR middle-end/120024 */
+
+void *f(unsigned) __attribute__((malloc));
+void g()
+{
+ void *(*g)(unsigned) = f;
+ void (*h)(unsigned) = (void (*)(unsigned))g;
+ h(1);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/malloc-2.c b/gcc/testsuite/gcc.dg/torture/malloc-2.c
new file mode 100644
index 0000000..8eeca9d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/malloc-2.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* PR middle-end/120024 */
+
+void *f(unsigned) __attribute__((malloc));
+void h1(void);
+void g(void)
+{
+ void *(*g)(unsigned) = f;
+ void (*h)(unsigned) = (void (*)(unsigned))g;
+ h(1);
+ h1();
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr121279-1.c b/gcc/testsuite/gcc.dg/torture/pr121279-1.c
new file mode 100644
index 0000000..516b887
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr121279-1.c
@@ -0,0 +1,49 @@
+/* { dg-do run } */
+/* PR tree-optimization/121279 */
+
+#include <stdbool.h>
+
+struct Value {
+ int type;
+ union {
+ bool boolean;
+ long long t;
+ };
+};
+
+static struct Value s_item_mem;
+
+/* truthy was being miscompiled for the value.type==2 case,
+ because the bool load from the union is pulled out of the
+ loop but that was conditional before and now it is not,
+ so turns it into `s_item_mem.type == 1 | bool` which is
+ not valid if `s_item_mem.type == 2` . */
+static bool truthy(void) __attribute__((noipa));
+static bool
+truthy(void)
+{
+ bool tt = false;
+ for(int i = 0; i < 10; i++)
+ {
+ if (s_item_mem.type == 0)
+ tt = tt | 0;
+ else if (s_item_mem.type == 1)
+ tt = tt | s_item_mem.boolean;
+ else
+ tt = tt | 1;
+ }
+ return tt;
+}
+
+int
+main(void)
+{
+ s_item_mem.type = 2;
+ s_item_mem.t = -1;
+ bool b1 = !truthy();
+ s_item_mem.type = 1;
+ s_item_mem.boolean = b1;
+ bool b = truthy();
+ if (b1 != b) __builtin_abort();
+ if (b) __builtin_abort();
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr121422-1.c b/gcc/testsuite/gcc.dg/torture/pr121422-1.c
new file mode 100644
index 0000000..136f80d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr121422-1.c
@@ -0,0 +1,35 @@
+/* { dg-do run } */
+/* PR tree-optimization/121422 */
+
+struct s1
+{
+ char a[4];
+};
+struct s1 b;
+char t[4];
+
+/* if both t and b startout zero initialized before this function,
+ t should end up being:
+ {0, 0, 1, 0}
+ while b.a should end up being:
+ {0, 0, 0, 1}
+*/
+__attribute__((noipa,noinline))
+void f(void)
+{
+ b = (struct s1){};
+ b.a[3] = 1;
+ /* This memcpy should stay a memcpy and not become memset. */
+ __builtin_memcpy(&t[0], &b.a[1], 3*sizeof(t[0]));
+}
+
+
+int main()
+{
+ f();
+ for(int i = 0; i < 4; i++)
+ {
+ if (t[i] != (i == 2 ? 1 : 0))
+ __builtin_abort();
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr121422-2.c b/gcc/testsuite/gcc.dg/torture/pr121422-2.c
new file mode 100644
index 0000000..570559c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr121422-2.c
@@ -0,0 +1,36 @@
+/* { dg-do run } */
+/* PR tree-optimization/121422 */
+
+struct s1
+{
+ char a[4];
+};
+struct s1 b;
+char t[4];
+
+/* if both t and b startout zero initialized before this function,
+ t should end up being:
+ {0, 0, 1, 0}
+ while b.a should end up being:
+ {0, 0, 0, 1}
+*/
+__attribute__((noipa,noinline))
+void f(void)
+{
+ __builtin_memset(&b.a[1], 0, 2);
+ b.a[3] = 1;
+ /* This memcpy should stay a memcpy and not become memset. */
+ __builtin_memcpy(&t[0], &b.a[1], 3);
+}
+
+
+int main()
+{
+ f();
+ for(int i = 0; i < 4; i++)
+ {
+ if (t[i] != (i == 2 ? 1 : 0))
+ __builtin_abort();
+ }
+}
+
diff --git a/gcc/testsuite/gcc.dg/torture/pr121478-1.c b/gcc/testsuite/gcc.dg/torture/pr121478-1.c
new file mode 100644
index 0000000..1dda01c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr121478-1.c
@@ -0,0 +1,32 @@
+/* { dg-do compile } */
+/* { dg-options "-std=gnu23" } */
+
+#include <stddef.h>
+#include <stdlib.h>
+typedef struct {
+ int data[5];
+ nullptr_t np;
+} container_t;
+void process_array(int *arr, size_t len, nullptr_t nullp) {
+ for (size_t i = 0; i < len; ++i) {
+ switch (arr[i] % 4) {
+ case 1:
+ if (nullp == nullptr) {
+ arr[i] *= -1;
+ [[fallthrough]];
+ }
+ case 2:
+ arr[i] = abs(arr[i]);
+ break;
+ default:
+ arr[i] = 0;
+ }
+ }
+}
+int main(void) {
+ container_t c = {
+ .data = { -3, 1, 4, 2, 7 },
+ .np = nullptr
+ };
+ process_array(c.data, 5, c.np);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr121514.c b/gcc/testsuite/gcc.dg/torture/pr121514.c
new file mode 100644
index 0000000..95b7a0b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr121514.c
@@ -0,0 +1,20 @@
+/* { dg-do compile { target int128 } } */
+/* { dg-additional-options "-Wno-psabi" } */
+
+typedef unsigned U __attribute__((__vector_size__(64)));
+typedef char V __attribute__((vector_size(64)));
+typedef __int128 W __attribute__((vector_size(64)));
+char c;
+int i;
+U u;
+V v;
+W w;
+
+W
+foo()
+{
+ u = 0 <= u;
+ __builtin_mul_overflow(i, c, &u[7]);
+ v ^= (V)u;
+ return (W)u + w;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr121656.c b/gcc/testsuite/gcc.dg/torture/pr121656.c
new file mode 100644
index 0000000..343d414
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr121656.c
@@ -0,0 +1,30 @@
+/* { dg-do run } */
+
+/* This test fails to run at -O1 and above. This is caused by
+
+ ebbeaf490c5 [PR rtl-optimization/120553] Improve selecting between constants based on sign bit test
+
+ and has been fixed by
+
+ 56ca14c4c4f Fix invalid right shift count with recent ifcvt changes
+
+ */
+
+__attribute__ ((noipa))
+void
+foo (int b)
+{
+ if (b != 3)
+ __builtin_abort ();
+}
+
+int a;
+int
+main ()
+{
+ int b = 0;
+ if (a >= 0)
+ b += 3;
+ foo (b);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr121695-1.c b/gcc/testsuite/gcc.dg/torture/pr121695-1.c
new file mode 100644
index 0000000..877c9c9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr121695-1.c
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+/* PR tree-optimization/121695 */
+
+int ac;
+char p;
+int *r;
+static unsigned t = 7;
+int q() {
+ int v;
+af: {
+ int ag[3];
+ int *ah = &ag[1];
+ for (; ac;) {
+ int ai = 3971866093;
+ if (0 >= *ah && (*r = 1))
+ *ah &= ai;
+ else {
+ if (p)
+ goto af;
+ *ah &= t;
+ }
+ }
+}
+ return v;
+}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-arg-1.c b/gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-arg-1.c
new file mode 100644
index 0000000..2ce6891
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-arg-1.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-optimized -fdump-tree-forwprop1-details" } */
+
+struct s1
+{
+ int t[1024];
+};
+
+void f(struct s1);
+
+void g(struct s1 a)
+{
+ struct s1 temp_struct0 = a;
+ f(temp_struct0);
+}
+
+/* There should be no references to any of "temp_struct*"
+ temporaries. */
+/* { dg-final { scan-tree-dump-times "temp_struct" 0 "optimized" } } */
+/* Also check that forwprop pass did the copy prop. */
+/* { dg-final { scan-tree-dump-times "after previous" 1 "forwprop1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-zero-1.c b/gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-zero-1.c
new file mode 100644
index 0000000..577a5b5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-zero-1.c
@@ -0,0 +1,28 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -fno-tree-sra -fdump-tree-optimized -fdump-tree-forwprop1-details" } */
+
+extern void link_error (void);
+
+/* Check for copyprop on structs with zeroing. */
+#define vector16 __attribute__((vector_size(64)))
+
+struct g
+{
+ vector16 unsigned char t;
+};
+
+struct g f(void)
+{
+ struct g temp_struct1 ;
+ temp_struct1.t = (vector16 unsigned char){};
+ struct g temp_struct2 = temp_struct1;
+ struct g temp_struct3 = temp_struct2;
+ struct g temp_struct4 = temp_struct3;
+ return temp_struct4;
+}
+
+/* There should be no references to any of "temp_struct*"
+ temporaries. */
+/* { dg-final { scan-tree-dump-times "temp_struct" 0 "optimized" } } */
+/* Also check that forwprop pass did the copy prop. */
+/* { dg-final { scan-tree-dump-times "after previous" 4 "forwprop1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-zero-2.c b/gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-zero-2.c
new file mode 100644
index 0000000..ce3c612
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-zero-2.c
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -fno-tree-sra -fdump-tree-optimized -fdump-tree-forwprop1-details" } */
+
+extern void link_error (void);
+
+struct g
+{
+ unsigned int t;
+};
+
+struct g f(void)
+{
+ struct g temp_struct1 ;
+ temp_struct1.t = 0;
+ struct g temp_struct2 = temp_struct1;
+ struct g temp_struct3 = temp_struct2;
+ struct g temp_struct4 = temp_struct3;
+ return temp_struct4;
+}
+
+/* There should be no references to any of "temp_struct*"
+ temporaries. */
+/* { dg-final { scan-tree-dump-times "temp_struct" 0 "optimized" } } */
+/* Also check that forwprop pass did the copy prop. */
+/* { dg-final { scan-tree-dump-times "after previous" 4 "forwprop1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-zero-3.c b/gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-zero-3.c
new file mode 100644
index 0000000..94ce965
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/copy-prop-aggregate-zero-3.c
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -fno-tree-sra -fdump-tree-optimized -fdump-tree-forwprop1-details" } */
+
+extern void link_error (void);
+
+struct g
+{
+ _Complex unsigned int t;
+};
+
+struct g f(void)
+{
+ struct g temp_struct1 ;
+ temp_struct1.t = 0;
+ struct g temp_struct2 = temp_struct1;
+ struct g temp_struct3 = temp_struct2;
+ struct g temp_struct4 = temp_struct3;
+ return temp_struct4;
+}
+
+/* There should be no references to any of "temp_struct*"
+ temporaries. */
+/* { dg-final { scan-tree-dump-times "temp_struct" 0 "optimized" } } */
+/* Also check that forwprop pass did the copy prop. */
+/* { dg-final { scan-tree-dump-times "after previous" 4 "forwprop1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-108.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-108.c
new file mode 100644
index 0000000..a13e972
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-108.c
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-options "-O -Wno-psabi -fdump-tree-fre1" } */
+
+#define vector16 __attribute__((vector_size(16)))
+#define vector32 __attribute__((vector_size(32)))
+
+union u1
+{
+ struct s1
+ {
+ vector16 int hi;
+ vector16 int low;
+ }hilow;
+ vector32 int v;
+};
+
+vector16 float f(vector16 int a, vector16 int b)
+{
+ union u1 c;
+ c.hilow.hi = a;
+ c.hilow.low = b;
+ vector32 int d0 = c.v;
+ vector32 float d = (vector32 float)d0;
+ vector16 float e = __builtin_shufflevector (d, d, 0, 1, 2, 3);
+ vector16 float f = __builtin_shufflevector (d, d, 4, 5, 6, 7);
+ return e/f;
+}
+
+/* { dg-final { scan-tree-dump-times "_\[0-9\]\+ = VIEW_CONVERT_EXPR" 2 "fre1" } } */
+/* { dg-final { scan-tree-dump-not "BIT_FIELD_REF" "fre1" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-109.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-109.c
new file mode 100644
index 0000000..f04e033c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-109.c
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fno-tree-sra -fdump-tree-fre1" } */
+
+struct s1
+{
+ int t;
+};
+
+struct s2
+{
+ struct s1 t;
+};
+
+int f1(int a)
+{
+ struct s1 t = (struct s1){a};
+ struct s2 tt = (struct s2){t};
+ struct s2 ttt = tt;
+ struct s1 *t0 = &ttt.t;
+ return t0->t;
+}
+
+/* { dg-final { scan-tree-dump "return a" "fre1" } } */
diff --git a/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-2.c b/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-2.c
new file mode 100644
index 0000000..b0cf36e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-2.c
@@ -0,0 +1,53 @@
+/* Test the attribute counted_by for pointer fields and its usage in
+ bounds sanitizer combined with VLA. */
+/* { dg-do run } */
+/* { dg-options "-fsanitize=bounds" } */
+/* { dg-output "index 11 out of bounds for type 'int \\\[\\\*\\\]\\\[\\\*\\\]'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*index 20 out of bounds for type 'int \\\[\\\*\\\]\\\[\\\*\\\]\\\[\\\*\\\]'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*index 11 out of bounds for type 'int \\\[\\\*\\\]\\\[\\\*\\\]'\[^\n\r]*(\n|\r\n|\r)" } */
+/* { dg-output "\[^\n\r]*index 10 out of bounds for type 'int \\\[\\\*\\\]'\[^\n\r]*(\n|\r\n|\r)" } */
+
+
+#include <stdlib.h>
+
+void __attribute__((__noinline__)) setup_and_test_vla (const int n, int m)
+{
+ struct foo {
+ int n;
+ int (*p)[n] __attribute__((counted_by(n)));
+ } *f;
+
+ f = (struct foo *) malloc (sizeof (struct foo));
+ f->p = (int (*)[n]) malloc (m * sizeof (int[n]));
+ f->n = m;
+ f->p[m][n-1] = 1;
+ free (f->p);
+ free (f);
+ return;
+}
+
+void __attribute__((__noinline__)) setup_and_test_vla_1 (const int n1,
+ const int n2,
+ int m)
+{
+ struct foo {
+ int n;
+ int (*p)[n2][n1] __attribute__((counted_by(n)));
+ } *f;
+
+ f = (struct foo *) malloc (sizeof(struct foo));
+ f->p = (int (*)[n2][n1]) malloc (m * sizeof (int[n2][n1]));
+ f->n = m;
+ f->p[m][n2][n1] = 1;
+ free (f->p);
+ free (f);
+ return;
+}
+
+int main(int argc, char *argv[])
+{
+ setup_and_test_vla (10, 11);
+ setup_and_test_vla_1 (10, 11, 20);
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-3.c b/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-3.c
new file mode 100644
index 0000000..731422d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-3.c
@@ -0,0 +1,42 @@
+/* Test the attribute counted_by for pointer fields and its usage in bounds
+ sanitizer. when counted_by field is negative value. */
+/* { dg-do run } */
+/* { dg-options "-fsanitize=bounds" } */
+
+#include <stdlib.h>
+
+struct annotated {
+ int b;
+ int *c __attribute__ ((counted_by (b)));
+} *array_annotated;
+
+void __attribute__((__noinline__)) setup (int annotated_count)
+{
+ array_annotated
+ = (struct annotated *)malloc (sizeof (struct annotated));
+ array_annotated->c = (int *) malloc (sizeof (int) * 10);
+ array_annotated->b = annotated_count;
+
+ return;
+}
+
+void __attribute__((__noinline__)) test (int annotated_index)
+{
+ array_annotated->c[annotated_index] = 2;
+}
+
+void cleanup ()
+{
+ free (array_annotated->c);
+ free (array_annotated);
+}
+
+int main(int argc, char *argv[])
+{
+ setup (-3);
+ test (2);
+ cleanup ();
+ return 0;
+}
+
+/* { dg-output "25:21: runtime error: index 2 out of bounds for type" } */
diff --git a/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-4.c b/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-4.c
new file mode 100644
index 0000000..52f202f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-4.c
@@ -0,0 +1,42 @@
+/* Test the attribute counted_by for pointer fields and its usage in bounds
+ sanitizer. when counted_by field is zero value. */
+/* { dg-do run } */
+/* { dg-options "-fsanitize=bounds" } */
+
+#include <stdlib.h>
+
+struct annotated {
+ int b;
+ int *c __attribute__ ((counted_by (b)));
+} *array_annotated;
+
+void __attribute__((__noinline__)) setup (int annotated_count)
+{
+ array_annotated
+ = (struct annotated *)malloc (sizeof (struct annotated));
+ array_annotated->c = (int *)malloc (sizeof (int) * 10);
+ array_annotated->b = annotated_count;
+
+ return;
+}
+
+void __attribute__((__noinline__)) test (int annotated_index)
+{
+ array_annotated->c[annotated_index] = 2;
+}
+
+void cleanup ()
+{
+ free (array_annotated->c);
+ free (array_annotated);
+}
+
+int main(int argc, char *argv[])
+{
+ setup (0);
+ test (1);
+ cleanup ();
+ return 0;
+}
+
+/* { dg-output "25:21: runtime error: index 1 out of bounds for type" } */
diff --git a/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-5.c b/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-5.c
new file mode 100644
index 0000000..8ad7572
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds-5.c
@@ -0,0 +1,40 @@
+/* Test the attribute counted_by for pointer fields and its usage in
+ bounds sanitizer. */
+/* { dg-do run } */
+/* { dg-options "-fsanitize=bounds" } */
+
+#include <stdlib.h>
+
+struct annotated {
+ int b;
+ int *c __attribute__ ((counted_by (b)));
+} *p_array_annotated;
+
+void __attribute__((__noinline__)) setup (int annotated_count)
+{
+ p_array_annotated
+ = (struct annotated *)malloc (sizeof (struct annotated));
+ p_array_annotated->c = (int *) malloc (annotated_count * sizeof (int));
+ p_array_annotated->b = annotated_count;
+
+ return;
+}
+
+void cleanup ()
+{
+ free (p_array_annotated->c);
+ free (p_array_annotated);
+}
+
+int main(int argc, char *argv[])
+{
+ int i;
+ setup (10);
+ for (i = 0; i < 11; i++)
+ p_array_annotated->c[i] = 2; // goes boom at i == 10
+ cleanup ();
+ return 0;
+}
+
+
+/* { dg-output "34:25: runtime error: index 10 out of bounds for type" } */
diff --git a/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds.c b/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds.c
new file mode 100644
index 0000000..c5a1ac5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ubsan/pointer-counted-by-bounds.c
@@ -0,0 +1,46 @@
+/* Test the attribute counted_by for pointer fields and its usage in
+ bounds sanitizer. */
+/* { dg-do run } */
+/* { dg-options "-fsanitize=bounds" } */
+
+#include <stdlib.h>
+
+struct pointer_array {
+ int b;
+ int *c;
+} *p_array;
+
+struct annotated {
+ int b;
+ int *c __attribute__ ((counted_by (b)));
+} *p_array_annotated;
+
+void __attribute__((__noinline__)) setup (int normal_count, int annotated_count)
+{
+ p_array
+ = (struct pointer_array *) malloc (sizeof (struct pointer_array));
+ p_array->c = (int *) malloc (normal_count * sizeof (int));
+ p_array->b = normal_count;
+
+ p_array_annotated
+ = (struct annotated *) malloc (sizeof (struct annotated));
+ p_array_annotated->c = (int *) malloc (annotated_count * sizeof (int));
+ p_array_annotated->b = annotated_count;
+
+ return;
+}
+
+void __attribute__((__noinline__)) test (int normal_index, int annotated_index)
+{
+ p_array->c[normal_index] = 1;
+ p_array_annotated->c[annotated_index] = 2;
+}
+
+int main(int argc, char *argv[])
+{
+ setup (10, 10);
+ test (10, 10);
+ return 0;
+}
+
+/* { dg-output "36:23: runtime error: index 10 out of bounds for type" } */
diff --git a/gcc/testsuite/gcc.dg/vect/pr121509.c b/gcc/testsuite/gcc.dg/vect/pr121509.c
new file mode 100644
index 0000000..3a69ad3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr121509.c
@@ -0,0 +1,42 @@
+/* { dg-additional-options "-fgimple" } */
+
+#include "tree-vect.h"
+
+long g_73[2] = {6L,6L};
+int __GIMPLE (ssa,startwith("loop")) __attribute__((noipa))
+foo ()
+{
+ signed char g;
+ int l;
+ int _1;
+ unsigned char _3;
+ unsigned char _4;
+
+ __BB(2):
+ goto __BB3;
+
+ __BB(3,loop_header(1)):
+ l_5 = __PHI (__BB2: _Literal (int) -511973466, __BB3: 1);
+ g_6 = __PHI (__BB2: _Literal (signed char) 0, __BB3: g_12);
+ _1 = (int) g_6;
+ g_73[_1] = 0l;
+ _3 = (unsigned char) g_6;
+ _4 = _3 + _Literal (unsigned char) 1;
+ g_12 = (signed char) _4;
+ if (g_12 > _Literal (signed char) 1)
+ goto __BB4;
+ else
+ goto __BB3;
+
+ __BB(4):
+ l_14 = __PHI (__BB3: l_5);
+ return l_14;
+}
+
+int main()
+{
+ check_vect ();
+ if (foo () != 1)
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/vect/pr121638.c b/gcc/testsuite/gcc.dg/vect/pr121638.c
new file mode 100644
index 0000000..52d5d6d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr121638.c
@@ -0,0 +1,74 @@
+/* { dg-additional-options "-fgimple -fno-tree-scev-cprop" } */
+
+#include "tree-vect.h"
+
+int a, b, f, j, i, *m, n, o, p = 1, q;
+
+int __GIMPLE (ssa,guessed_local(1073741824),startwith("loop"))
+main ()
+{
+ int D_3005;
+ int D_3003;
+ int d;
+ int * e;
+ long unsigned int _9;
+ long unsigned int _10;
+ int * _11;
+ int _15;
+ int _32;
+
+ __BB(2,guessed_local(1073741824)):
+ check_vect ();
+ e_6 = __builtin_malloc (64ul);
+ goto __BB3(precise(134217728));
+
+ __BB(3,loop_header(2),guessed_local(8687547538)):
+ d_29 = __PHI (__BB3: d_8, __BB2: 0);
+ d_8 = d_29 + 1;
+ _9 = (long unsigned int) d_29;
+ _10 = _9 * 4ul;
+ _11 = e_6 + _10;
+ __MEM <int> (_11) = d_29;
+ if (d_8 <= 15)
+ goto __BB3(guessed(119453778));
+ else
+ goto __BB4(guessed(14763950));
+
+ __BB(4,guessed_local(955630224)):
+ if (d_8 != 16)
+ goto __BB9(guessed(58814510));
+ else
+ goto __BB5(guessed(75403218));
+
+ __BB(5,guessed_local(536870912)):
+ a = 0;
+ if (d_8 > 0)
+ goto __BB6(guessed(119453778));
+ else
+ goto __BB8(guessed(14763950));
+
+ __BB(6,loop_header(1),guessed_local(4343773769)):
+ _32 = __PHI (__BB6: _15, __BB5: 0);
+ _15 = _32 + 1;
+ if (d_29 > _32)
+ goto __BB6(guessed(119453778));
+ else
+ goto __BB7(guessed(14763950));
+
+ __BB(7,guessed_local(477815112)):
+ a = _15;
+ goto __BB8(precise(134217728));
+
+ __BB(8,guessed_local(1073741824)):
+ __builtin_free (e_6);
+ f = 0;
+ return 0;
+
+ __BB(9,precise(0)):
+ a = d_8;
+ f = 1;
+ __builtin_abort ();
+
+}
+
+
diff --git a/gcc/testsuite/gcc.dg/vect/pr121659.c b/gcc/testsuite/gcc.dg/vect/pr121659.c
new file mode 100644
index 0000000..19d5f8c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr121659.c
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+
+_Bool a;
+void b(_Bool c[][3])
+{
+ for (short d = 0; d < 100; d++)
+ for (int e = 1; e < 21; e += 4)
+ a ^= !c[1][1];
+ for (;;)
+ ;
+}
diff --git a/gcc/testsuite/gcc.dg/vect/pr121686.c b/gcc/testsuite/gcc.dg/vect/pr121686.c
new file mode 100644
index 0000000..5a9284c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr121686.c
@@ -0,0 +1,32 @@
+/* { dg-additional-options "-O3" } */
+
+#include "tree-vect.h"
+
+signed char a, b, c, f;
+int d, e, g, h;
+
+int main()
+{
+ int j, k;
+ signed char m;
+ check_vect ();
+ while (f < 4) {
+ k = b = 3;
+ for (; b >= 0; b--) {
+ j = a < 0 ? a : a >> h;
+ g = k;
+ e = j;
+ k = 0;
+ while (1) {
+ if (j)
+ break;
+ k = f == 0;
+ break;
+ }
+ }
+ m = g * 87;
+ if (m < 70)
+ __builtin_abort();
+ return 0;
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/vect/pr121744-1.c b/gcc/testsuite/gcc.dg/vect/pr121744-1.c
new file mode 100644
index 0000000..81f4996
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr121744-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-mavx2" { target avx2 } } */
+
+unsigned long a[1024];
+unsigned int b[1024];
+
+void foo()
+{
+ for (int i = 0; i < 1024; ++i)
+ a[i] = 1ul << b[i];
+}
+
+/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { target vect_var_shift } } } */