diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg')
179 files changed, 3453 insertions, 81 deletions
diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-47.c b/gcc/testsuite/gcc.dg/Wstringop-overflow-47.c index aa5402a..6fb64ae 100644 --- a/gcc/testsuite/gcc.dg/Wstringop-overflow-47.c +++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-47.c @@ -31,15 +31,15 @@ void nowarn_c32 (char c) void warn_c32 (char c) { - extern char warn_a32[32]; // { dg-message "at offset (32|1|17) into destination object 'warn_a32' of size 32" "pr97027" } + extern char warn_a32[32]; // { dg-message "at offset (32|1|17|29) into destination object 'warn_a32' of size 32" "pr97027" } void *p = warn_a32 + 1; - *(C32*)p = (C32){ c }; // { dg-warning "writing (1 byte|16 bytes|32 bytes) into a region of size (0|15|31)" "pr97027" } + *(C32*)p = (C32){ c }; // { dg-warning "writing (1 byte|16 bytes|32 bytes|4 bytes) into a region of size (0|15|31|3)" "pr97027" } /* Verify a local variable too. */ char a32[32]; p = a32 + 1; - *(C32*)p = (C32){ c }; // { dg-warning "writing (1 byte|16 bytes|32 bytes) into a region of size (0|15|31)" "pr97027" } + *(C32*)p = (C32){ c }; // { dg-warning "writing (1 byte|16 bytes|32 bytes|4 bytes) into a region of size (0|15|31|3)" "pr97027" } sink (p); } diff --git a/gcc/testsuite/gcc.dg/analyzer/setjmp-3-sarif.py b/gcc/testsuite/gcc.dg/analyzer/setjmp-3-sarif.py new file mode 100644 index 0000000..922d338 --- /dev/null +++ b/gcc/testsuite/gcc.dg/analyzer/setjmp-3-sarif.py @@ -0,0 +1,23 @@ +from sarif import * + +import pytest + +@pytest.fixture(scope='function', autouse=True) +def sarif(): + return sarif_from_env() + +def test_kinds(sarif): + result = get_result_by_index(sarif, 0) + + assert result['level'] == 'note' + + events = result["codeFlows"][0]["threadFlows"][0]['locations'] + + assert events[1]['location']['message']['text'] == "'setjmp' called here" + assert events[1]['kinds'] == ["setjmp"] + + assert events[6]['location']['message']['text'] == "rewinding from 'longjmp' in 'inner'..." + assert events[6]['kinds'] == ["longjmp"] + + assert events[7]['location']['message']['text'].startswith("...to 'setjmp' in 'outer'") + assert events[7]['kinds'] == ["longjmp"] diff --git a/gcc/testsuite/gcc.dg/analyzer/setjmp-3.c b/gcc/testsuite/gcc.dg/analyzer/setjmp-3.c index 3e4f870..a19ce84 100644 --- a/gcc/testsuite/gcc.dg/analyzer/setjmp-3.c +++ b/gcc/testsuite/gcc.dg/analyzer/setjmp-3.c @@ -1,4 +1,6 @@ /* { dg-additional-options "-fdiagnostics-show-line-numbers -fdiagnostics-path-format=inline-events -fdiagnostics-show-caret" } */ +/* { dg-additional-options "-fdiagnostics-add-output=sarif" } */ + /* { dg-enable-nn-line-numbers "" } */ /* { dg-require-effective-target indirect_jumps } */ @@ -107,3 +109,10 @@ void outer (void) | | (11) here | { dg-end-multiline-output "" } */ + +/* Verify that some JSON was written to a file with the expected name. */ +/* { dg-final { verify-sarif-file } } */ + +/* Use a Python script to verify various properties about the generated + .sarif file: + { dg-final { run-sarif-pytest setjmp-3.c "setjmp-3-sarif.py" } } */ diff --git a/gcc/testsuite/gcc.dg/analyzer/strchr-1.c b/gcc/testsuite/gcc.dg/analyzer/strchr-1.c index 181f182..5cc5fe5 100644 --- a/gcc/testsuite/gcc.dg/analyzer/strchr-1.c +++ b/gcc/testsuite/gcc.dg/analyzer/strchr-1.c @@ -1,4 +1,3 @@ -#include <string.h> #include "analyzer-decls.h" const char* test_literal (int x) @@ -14,28 +13,28 @@ const char* test_literal (int x) return p; } -void test_2 (const char *s, int c) +void test_2 (char *s, int c) { char *p = __builtin_strchr (s, c); /* { dg-message "when '__builtin_strchr' returns NULL" } */ *p = 'A'; /* { dg-warning "dereference of NULL 'p'" "null deref" } */ } -void test_3 (const char *s, int c) +void test_3 (char *s, int c) { - char *p = strchr (s, c); /* { dg-message "when 'strchr' returns NULL" } */ + char *p = __builtin_strchr (s, c); /* { dg-message "when '__builtin_strchr' returns NULL" } */ *p = 'A'; /* { dg-warning "dereference of NULL 'p'" "null deref" } */ } void test_unterminated (int c) { char buf[3] = "abc"; - strchr (buf, c); /* { dg-warning "stack-based buffer over-read" } */ - /* { dg-message "while looking for null terminator for argument 1 \\('&buf'\\) of 'strchr'..." "event" { target *-*-* } .-1 } */ + __builtin_strchr (buf, c); /* { dg-warning "stack-based buffer over-read" } */ + /* { dg-message "while looking for null terminator for argument 1 \\('&buf'\\) of '__builtin_strchr'..." "event" { target *-*-* } .-1 } */ } void test_uninitialized (int c) { char buf[16]; - strchr (buf, c); /* { dg-warning "use of uninitialized value 'buf\\\[0\\\]'" } */ - /* { dg-message "while looking for null terminator for argument 1 \\('&buf'\\) of 'strchr'..." "event" { target *-*-* } .-1 } */ + __builtin_strchr (buf, c); /* { dg-warning "use of uninitialized value 'buf\\\[0\\\]'" } */ + /* { dg-message "while looking for null terminator for argument 1 \\('&buf'\\) of '__builtin_strchr'..." "event" { target *-*-* } .-1 } */ } diff --git a/gcc/testsuite/gcc.dg/asm-hard-reg-9.c b/gcc/testsuite/gcc.dg/asm-hard-reg-9.c new file mode 100644 index 0000000..f2079ec --- /dev/null +++ b/gcc/testsuite/gcc.dg/asm-hard-reg-9.c @@ -0,0 +1,15 @@ +/* { dg-do compile { target { s390*-*-* || { x86_64-*-* && lp64 } } } } */ +/* { dg-options "-O2" } */ + +/* Ensure that if the reload register for operand 2 is resued for operand 3, + that exclude start hard regs coming from operand 3 are taken into account. + Otherwise a different register than r8 may be chosen rendering the insn + after LRA unsatisfiable. */ + +long +test () +{ + long x; + __asm__ ("" : "=r" (x) : "0" (1000), "r" (0l), "{r8}" (0l)); + return x; +} diff --git a/gcc/testsuite/gcc.dg/builtin-assume-aligned-1.c b/gcc/testsuite/gcc.dg/builtin-assume-aligned-1.c index a74ecce..01aa884 100644 --- a/gcc/testsuite/gcc.dg/builtin-assume-aligned-1.c +++ b/gcc/testsuite/gcc.dg/builtin-assume-aligned-1.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O3 -fdump-tree-optimized" } */ +/* { dg-options "-O3 -fno-tree-vectorize -fdump-tree-optimized-alias" } */ void test1 (double *out1, double *out2, double *out3, double *in1, @@ -19,6 +19,8 @@ test1 (double *out1, double *out2, double *out3, double *in1, } } +/* { dg-final { scan-tree-dump-times " ALIGN = 16, MISALIGN = 0" 5 "optimized" } } */ + void test2 (double *out1, double *out2, double *out3, double *in1, double *in2, int len) @@ -37,4 +39,8 @@ test2 (double *out1, double *out2, double *out3, double *in1, } } -/* { dg-final { scan-tree-dump-not "__builtin_assume_aligned" "optimized" } } */ + +/* { dg-final { scan-tree-dump-times " ALIGN = 32" 5 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " ALIGN = 32, MISALIGN = 16" 4 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " ALIGN = 32, MISALIGN = 0" 1 "optimized" } } */ + diff --git a/gcc/testsuite/gcc.dg/cmp-mem-const-1.c b/gcc/testsuite/gcc.dg/cmp-mem-const-1.c index 0b0e733..4f94902 100644 --- a/gcc/testsuite/gcc.dg/cmp-mem-const-1.c +++ b/gcc/testsuite/gcc.dg/cmp-mem-const-1.c @@ -1,6 +1,7 @@ /* { dg-do compile { target { lp64 } } } */ /* { dg-options "-O2 -fdump-rtl-combine-details" } */ /* { dg-final { scan-rtl-dump "narrow comparison from mode .I to QI" "combine" } } */ +/* { dg-skip-if "" { riscv*-*-* } } */ typedef __UINT64_TYPE__ uint64_t; diff --git a/gcc/testsuite/gcc.dg/cmp-mem-const-2.c b/gcc/testsuite/gcc.dg/cmp-mem-const-2.c index 8022137..12d962a 100644 --- a/gcc/testsuite/gcc.dg/cmp-mem-const-2.c +++ b/gcc/testsuite/gcc.dg/cmp-mem-const-2.c @@ -1,6 +1,7 @@ /* { dg-do compile { target { lp64 } } } */ /* { dg-options "-O2 -fdump-rtl-combine-details" } */ /* { dg-final { scan-rtl-dump "narrow comparison from mode .I to QI" "combine" } } */ +/* { dg-skip-if "" { riscv*-*-* } } */ typedef __UINT64_TYPE__ uint64_t; diff --git a/gcc/testsuite/gcc.dg/compat/pr83487-1_x.c b/gcc/testsuite/gcc.dg/compat/pr83487-1_x.c index b5b208f..22b71cf 100644 --- a/gcc/testsuite/gcc.dg/compat/pr83487-1_x.c +++ b/gcc/testsuite/gcc.dg/compat/pr83487-1_x.c @@ -1,4 +1,5 @@ /* { dg-options "-fno-common" { target { hppa*-*-hpux* } } } */ +/* { dg-options "-Wno-psabi" { target { riscv*-*-* } } } */ #include "pr83487-1.h" extern diff --git a/gcc/testsuite/gcc.dg/compat/pr83487-1_y.c b/gcc/testsuite/gcc.dg/compat/pr83487-1_y.c index ad336dd..cf275d8 100644 --- a/gcc/testsuite/gcc.dg/compat/pr83487-1_y.c +++ b/gcc/testsuite/gcc.dg/compat/pr83487-1_y.c @@ -1,4 +1,5 @@ /* { dg-options "-fno-common" { target { hppa*-*-hpux* } } } */ +/* { dg-options "-Wno-psabi" { target { riscv*-*-* } } } */ #include "pr83487-1.h" struct A a; diff --git a/gcc/testsuite/gcc.dg/compat/pr83487-2_x.c b/gcc/testsuite/gcc.dg/compat/pr83487-2_x.c index 7103194..399ac86 100644 --- a/gcc/testsuite/gcc.dg/compat/pr83487-2_x.c +++ b/gcc/testsuite/gcc.dg/compat/pr83487-2_x.c @@ -1,3 +1,4 @@ /* { dg-options "-fno-common" { target { hppa*-*-hpux* } } } */ +/* { dg-options "-Wno-psabi" { target { riscv*-*-* } } } */ #define PR83487_LARGE #include "pr83487-1_x.c" diff --git a/gcc/testsuite/gcc.dg/compat/pr83487-2_y.c b/gcc/testsuite/gcc.dg/compat/pr83487-2_y.c index e176783..dc6c1f8 100644 --- a/gcc/testsuite/gcc.dg/compat/pr83487-2_y.c +++ b/gcc/testsuite/gcc.dg/compat/pr83487-2_y.c @@ -1,3 +1,4 @@ /* { dg-options "-fno-common" { target { hppa*-*-hpux* } } } */ +/* { dg-options "-Wno-psabi" { target { riscv*-*-* } } } */ #define PR83487_LARGE #include "pr83487-1_y.c" diff --git a/gcc/testsuite/gcc.dg/countof-compile.c b/gcc/testsuite/gcc.dg/countof-compile.c index afd5659..ebbac16 100644 --- a/gcc/testsuite/gcc.dg/countof-compile.c +++ b/gcc/testsuite/gcc.dg/countof-compile.c @@ -122,3 +122,9 @@ const_expr(void) _Static_assert (_Countof (int [3][n]) == 3); _Static_assert (_Countof (int [n][3]) == 7); /* { dg-error "not constant" } */ } + +void +type(void) +{ + _Generic (_Countof (w), __typeof__ (sizeof 0): 0); +} diff --git a/gcc/testsuite/gcc.dg/cpp/escape-3.i b/gcc/testsuite/gcc.dg/cpp/escape-3.i index 6eb7dc4..cb47581 100644 --- a/gcc/testsuite/gcc.dg/cpp/escape-3.i +++ b/gcc/testsuite/gcc.dg/cpp/escape-3.i @@ -13,4 +13,4 @@ int foo (int a, int b) } /* Test for "/some\\directory" instead of "/some\\\\directory" */ -/* { dg-final { scan-assembler { "/some\\\\directory" } } } */ +/* { dg-final { scan-assembler "/some\\\\\\\\directory" } } */ diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-prune-4.c b/gcc/testsuite/gcc.dg/debug/btf/btf-prune-4.c new file mode 100644 index 0000000..3f19559 --- /dev/null +++ b/gcc/testsuite/gcc.dg/debug/btf/btf-prune-4.c @@ -0,0 +1,61 @@ +/* Test that -gprune-btf does not prune at typedefs. */ + +/* { dg-do compile } */ +/* { dg-options "-gbtf -gprune-btf -dA" } */ + +/* We must have the full definitions of td1 and td3. Neither are pruned. + td2 will be skipped entirely, only because the only reference to + it is through struct inner, which is pruned because inner itself + is only used as a pointer member. + + In general, we must never get an anonymous FWD; the only FWD in this + case will be for 'inner' */ + +/* Exactly 1 FWD for inner and no anonymous FWD. */ +/* { dg-final { scan-assembler-times "TYPE \[0-9\]+ BTF_KIND_FWD" 1 } } */ +/* { dg-final { scan-assembler-not "TYPE \[0-9\]+ BTF_KIND_FWD ''" } } */ +/* { dg-final { scan-assembler " BTF_KIND_FWD 'inner'" } } */ + +/* One anonymous struct for td1 and one anonymous union for td3. */ +/* { dg-final { scan-assembler-times "TYPE \[0-9\]+ BTF_KIND_STRUCT ''" 1 } } */ +/* { dg-final { scan-assembler-times "TYPE \[0-9\]+ BTF_KIND_UNION ''" 1 } } */ + +/* The two remaining typedefs. */ +/* { dg-final { scan-assembler " BTF_KIND_TYPEDEF 'td1'" } } */ +/* { dg-final { scan-assembler " BTF_KIND_TYPEDEF 'td3'" } } */ + +typedef struct { + int x; + char c; +} td1; + +typedef struct { + long l; + char b[4]; +} td2; + +typedef union { + long l; + unsigned short s[2]; +} td3; + +struct inner { + char a; + td2 *ptd; + long z; +}; + +struct A { + td1 *pt; + struct inner *in; + unsigned long l[4]; +}; + +struct A foo; + +struct B { + int x; + td3 **ppptd3; +}; + +struct B bar; diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-decl-tag-1.c b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-decl-tag-1.c index a1c1676..38739e4 100644 --- a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-decl-tag-1.c +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-decl-tag-1.c @@ -5,7 +5,7 @@ int *foo __attribute__((btf_decl_tag ("my_foo"))); -/* { dg-final { scan-assembler-times "DIE \\(\[^\n\]*\\) DW_TAG_GNU_annotation" 1 } } */ -/* { dg-final { scan-assembler-times " DW_AT_name: \"btf_decl_tag\"" 1 } } */ -/* { dg-final { scan-assembler-times " DW_AT_const_value: \"my_foo\"" 1 } } */ -/* { dg-final { scan-assembler-times " DW_AT_GNU_annotation" 1 } } */ +/* { dg-final { scan-assembler-times {(?n)DIE \(.*\) DW_TAG_GNU_annotation} 1 } } */ +/* { dg-final { scan-assembler-times {(?n)( DW_AT_name: "btf_decl_tag"|"btf_decl_tag..".*DW_AT_name)} 1 } } */ +/* { dg-final { scan-assembler-times {(?n)( DW_AT_const_value: "my_foo"|"my_foo..".*DW_AT_const_value)} 1 } } */ +/* { dg-final { scan-assembler-times { DW_AT_GNU_annotation} 1 } } */ diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-decl-tag-4.c b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-decl-tag-4.c new file mode 100644 index 0000000..6fdcdc6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-decl-tag-4.c @@ -0,0 +1,28 @@ +/* Test DWARF generation for decl_tags on global decls appearing multiple + times with different decl_tags. PR122248. */ +/* { dg-do compile } */ +/* { dg-options "-gdwarf -dA" } */ + +#define __tag1 __attribute__((btf_decl_tag ("tag1"))) +#define __tag2 __attribute__((btf_decl_tag ("tag2"))) +#define __tag3 __attribute__((btf_decl_tag ("tag3"))) +#define __tag4 __attribute__((btf_decl_tag ("tag4"))) + +int foo __tag1; +int foo __tag2; + +/* Result: foo has __tag1 and __tag2. */ + +int bar __tag3; +int bar; + +/* Result: bar has __tag3. */ + +int baz; +int baz __tag4; + +/* Result: baz has __tag4. */ + +/* { dg-final { scan-assembler-times "DIE \\(\[^\n\]*\\) DW_TAG_GNU_annotation" 4 } } */ +/* { dg-final { scan-assembler-times " DW_AT_GNU_annotation" 4 } } */ + diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-decl-tag-5.c b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-decl-tag-5.c new file mode 100644 index 0000000..c7cb60c --- /dev/null +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-decl-tag-5.c @@ -0,0 +1,35 @@ +/* Test DWARF generation for decl_tags on global decls appearing multiple + times with different decl_tags. PR122248. */ +/* { dg-do compile } */ +/* { dg-options "-gdwarf -dA" } */ + +#define __tag1 __attribute__((btf_decl_tag ("tag1"))) +#define __tag2 __attribute__((btf_decl_tag ("tag2"))) +#define __tag3 __attribute__((btf_decl_tag ("tag3"))) + +struct S +{ + int x; + char c; +}; + +extern struct S foo __tag1; +struct S foo __tag2; + +/* Result: non-completing variable DIE for 'foo' has tag1, and the + completing DIE (with AT_specification) for 'foo' has tag2 -> tag1. */ + +extern int a __tag3; +int a; + +/* Result: non-completing variable DIE for a has tag3, and the + completing DIE (with AT_specification) for 'a' also refers to tag3. */ + +/* { dg-final { scan-assembler-times "DIE \\(\[^\n\]*\\) DW_TAG_GNU_annotation" 3 } } */ + +/* 5 AT_GNU annotations: + - foo -> tag1 + - foo -> tag2 -> tag1 + - a -> tag3 + - a -> tag3 */ +/* { dg-final { scan-assembler-times " DW_AT_GNU_annotation" 5 } } */ diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-decl-tag-6.c b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-decl-tag-6.c new file mode 100644 index 0000000..dd89d11 --- /dev/null +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-decl-tag-6.c @@ -0,0 +1,24 @@ +/* Test DWARF generation for decl_tags on global decls appearing multiple + times with different decl_tags. PR122248. */ +/* { dg-do compile } */ +/* { dg-options "-gdwarf -dA" } */ + +#define __tag1 __attribute__((btf_decl_tag ("tag1"))) +#define __tag2 __attribute__((btf_decl_tag ("tag2"))) +#define __tag3 __attribute__((btf_decl_tag ("tag3"))) + +__tag1 +extern int +do_thing (int); + +__tag2 +__tag3 +int +do_thing (int x) +{ + return x * x; +} + +/* Result: do_thing has all 3 tags. */ +/* { dg-final { scan-assembler-times "DIE \\(\[^\n\]*\\) DW_TAG_GNU_annotation" 3 } } */ +/* { dg-final { scan-assembler-times " DW_AT_GNU_annotation" 3 } } */ diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-type-tag-1.c b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-type-tag-1.c index 772aab0..437b981 100644 --- a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-type-tag-1.c +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-type-tag-1.c @@ -4,7 +4,7 @@ int * __attribute__((btf_type_tag("__user"))) ptr; -/* { dg-final { scan-assembler-times "DIE \\(\[^\n\]*\\) DW_TAG_GNU_annotation" 1 } } */ -/* { dg-final { scan-assembler-times " DW_AT_name: \"btf_type_tag\"" 1 } } */ -/* { dg-final { scan-assembler-times " DW_AT_const_value: \"__user\"" 1 } } */ -/* { dg-final { scan-assembler-times " DW_AT_GNU_annotation" 1 } } */ +/* { dg-final { scan-assembler-times {(?n)DIE \(.*\) DW_TAG_GNU_annotation} 1 } } */ +/* { dg-final { scan-assembler-times {(?n)( DW_AT_name: "btf_type_tag"| "btf_type_tag..".*DW_AT_name)} 1 } } */ +/* { dg-final { scan-assembler-times {(?n)( DW_AT_const_value: "__user"|"__user..".*DW_AT_const_value)} 1 } } */ +/* { dg-final { scan-assembler-times { DW_AT_GNU_annotation} 1 } } */ diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-type-tag-10.c b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-type-tag-10.c index 3ecd79f..7af1452 100644 --- a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-type-tag-10.c +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-type-tag-10.c @@ -16,5 +16,5 @@ foo (int *x, int *y) /* Ideally, verify that AT_GNU_annotation in the subprogram DIE refers to the decl_tag annotation DIE, and the AT_GNU_annotation in the return type refers to the type_tag... */ -/* { dg-final { scan-assembler-times " DW_AT_name: \"btf_type_tag\"" 1 } } */ -/* { dg-final { scan-assembler-times " DW_AT_name: \"btf_decl_tag\"" 1 } } */ +/* { dg-final { scan-assembler-times {(?n)( DW_AT_name: "btf_type_tag"|"btf_type_tag..".*DW_AT_name)} 1 } } */ +/* { dg-final { scan-assembler-times {(?n)( DW_AT_name: "btf_decl_tag"|"btf_decl_tag..".*DW_AT_name)} 1 } } */ diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-type-tag-2.c b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-type-tag-2.c index 9c44e0e..467d759 100644 --- a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-type-tag-2.c +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-type-tag-2.c @@ -20,12 +20,12 @@ struct S * __tag1 __tag2 my_S; /* Only 2 DW_TAG_GNU_annotation DIEs should be generated, one each for "tag1" and "tag2", and they should be reused. */ -/* { dg-final { scan-assembler-times "DIE \\(\[^\n\]*\\) DW_TAG_GNU_annotation" 2 } } */ -/* { dg-final { scan-assembler-times " DW_AT_name: \"btf_type_tag\"" 2 } } */ -/* { dg-final { scan-assembler-times " DW_AT_const_value: \"tag1\"" 1 } } */ -/* { dg-final { scan-assembler-times " DW_AT_const_value: \"tag2\"" 1 } } */ +/* { dg-final { scan-assembler-times {(?n)DIE \(.*\) DW_TAG_GNU_annotation} 2 } } */ +/* { dg-final { scan-assembler-times { DW_AT_name: "btf_type_tag"} 2 } } */ +/* { dg-final { scan-assembler-times {(?n)( DW_AT_const_value: "tag1"|"tag1..".* DW_AT_const_value)} 1 } } */ +/* { dg-final { scan-assembler-times {(?n)( DW_AT_const_value: "tag2"|"tag2..".*DW_AT_const_value)} 1 } } */ /* Each attribute-ed type shall refer via DW_AT_GNU_annotation to the appropriate annotation DIE, including the annotation DIE for "tag2" which is always chained to the DIE for "tag1" in this construction. */ -/* { dg-final { scan-assembler-times " DW_AT_GNU_annotation" 5 } } */ +/* { dg-final { scan-assembler-times { DW_AT_GNU_annotation} 5 } } */ diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-type-tag-4.c b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-type-tag-4.c index 7205ef2..212cc4ec 100644 --- a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-type-tag-4.c +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-type-tag-4.c @@ -29,6 +29,6 @@ union U volatile union U volatile_u; /* One annotation DIE may be shared by all three annotated types. */ -/* { dg-final { scan-assembler-times "DIE \\(\[^\n\]*\\) DW_TAG_GNU_annotation" 1 } } */ -/* { dg-final { scan-assembler-times " DW_AT_name: \"btf_type_tag\"" 1 } } */ -/* { dg-final { scan-assembler-times " DW_AT_GNU_annotation" 3 } } */ +/* { dg-final { scan-assembler-times {(?n)DIE \(.*\) DW_TAG_GNU_annotation} 1 } } */ +/* { dg-final { scan-assembler-times {(?n)( DW_AT_name: "btf_type_tag"|"btf_type_tag..".* DW_AT_name)} 1 } } */ +/* { dg-final { scan-assembler-times { DW_AT_GNU_annotation} 3 } } */ diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-type-tag-5.c b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-type-tag-5.c index 1a6b29f..ffb2ca8 100644 --- a/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-type-tag-5.c +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/dwarf-btf-type-tag-5.c @@ -4,7 +4,7 @@ int arr[8] __attribute__((btf_type_tag("tagged_arr"))); -/* { dg-final { scan-assembler-times "DIE \\(\[^\n\]*\\) DW_TAG_GNU_annotation" 1 } } */ -/* { dg-final { scan-assembler-times " DW_AT_name: \"btf_type_tag\"" 1 } } */ -/* { dg-final { scan-assembler-times " DW_AT_const_value: \"tagged_arr\"" 1 } } */ -/* { dg-final { scan-assembler-times " DW_AT_GNU_annotation" 1 } } */ +/* { dg-final { scan-assembler-times {(?n)DIE \(.*\) DW_TAG_GNU_annotation} 1 } } */ +/* { dg-final { scan-assembler-times {(?n)( DW_AT_name: "btf_type_tag"|"btf_type_tag..".*)} 1 } } */ +/* { dg-final { scan-assembler-times {(?n)( DW_AT_const_value: "tagged_arr"|"tagged_arr..".*DW_AT_const_value)} 1 } } */ +/* { dg-final { scan-assembler-times { DW_AT_GNU_annotation} 1 } } */ diff --git a/gcc/testsuite/gcc.dg/fold-vecperm-1.c b/gcc/testsuite/gcc.dg/fold-vecperm-1.c index 5d4456b..878d392 100644 --- a/gcc/testsuite/gcc.dg/fold-vecperm-1.c +++ b/gcc/testsuite/gcc.dg/fold-vecperm-1.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-options "-O2 -fdump-tree-forwprop3" } */ typedef int v4si __attribute__((vector_size(16))); typedef short v8hi __attribute__((vector_size(16))); @@ -20,4 +20,4 @@ int128 concat (int128 a, int128 b) { return res; } -/* { dg-final { scan-tree-dump-times "VEC_PERM_EXPR" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "VEC_PERM_EXPR" 1 "forwprop3" } } */ diff --git a/gcc/testsuite/gcc.dg/gimplefe-58.c b/gcc/testsuite/gcc.dg/gimplefe-58.c new file mode 100644 index 0000000..b209ab6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gimplefe-58.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-fgimple" } */ + +int __GIMPLE (ssa) +foo (int * restrict p, int * q) +{ + int x; + int _1; + int _7; + + __BB(2): + x_4 = __MEM <int> (q_3(D), 1:0); + __MEM <int> ((int *)p_5(D), 1 :1) = 1; + _1 = __MEM <int> (q_3(D), 1: 0); + _7 = _1 + x_4; + return _7; +} diff --git a/gcc/testsuite/gcc.dg/gnu-compoundlit-1.c b/gcc/testsuite/gcc.dg/gnu-compoundlit-1.c new file mode 100644 index 0000000..a7f3496 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gnu-compoundlit-1.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu23" } */ + +int g(int n, int (*p)[n]); +int f(int n) +{ + return g(n, &(int[n]){ }); +} + +void h(int n) +{ + (int[n]){ 1 }; /* { dg-error "empty initializer" } */ +} + +void i(int n) +{ + (static int[3]){ }; + (static int[n]){ }; /* { dg-error "storage size" } */ + (constexpr int[3]){ }; + (constexpr int[n]){ }; /* { dg-error "storage size" } */ + (register int[3]){ }; /* { dg-error "register" } */ + (register int[n]){ }; /* { dg-error "register" } */ + (_Thread_local int[3]){ }; /* { dg-error "_Thread_local" } */ + (_Thread_local int[n]){ }; /* { dg-error "_Thread_local" } */ +} + diff --git a/gcc/testsuite/gcc.dg/gnu-compoundlit-2.c b/gcc/testsuite/gcc.dg/gnu-compoundlit-2.c new file mode 100644 index 0000000..dcc5775 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gnu-compoundlit-2.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-options "-std=gnu23 -Wall" } */ + +[[gnu::noinline,gnu::noipa]] +static bool f(int n) +{ + struct foo { char a[n]; }; + struct foo x = { }; + + return 0 == __builtin_memcmp(&x, &(struct foo){ }, sizeof x); +} + +int main() +{ + if (!f(7)) + __builtin_abort(); + + return 0; +} + diff --git a/gcc/testsuite/gcc.dg/gomp/pr110485.c b/gcc/testsuite/gcc.dg/gomp/pr110485.c index ba6817a..5183f3f 100644 --- a/gcc/testsuite/gcc.dg/gomp/pr110485.c +++ b/gcc/testsuite/gcc.dg/gomp/pr110485.c @@ -16,4 +16,4 @@ void foo (int n) } /* { dg-final { scan-tree-dump-not "MASK_LOAD" "vect" } } */ -/* { dg-final { scan-tree-dump "can't use a fully-masked loop because a non-masked simd clone was selected." "vect" { target x86_64-*-* } } } */ +/* { dg-final { scan-tree-dump "can't use a fully-masked loop because no masked simd clone was available" "vect" { target x86_64-*-* } } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/vrp-from-cst-agg-1.c b/gcc/testsuite/gcc.dg/ipa/vrp-from-cst-agg-1.c new file mode 100644 index 0000000..c18146a --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/vrp-from-cst-agg-1.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fdump-ipa-cp-details" } */ + +static const struct { + int w; + int h; +} sizes[7] = { + { 16, 16 }, + { 16, 8 }, + { 8, 16 }, + { 8, 8 }, + { 8, 4 }, + { 4, 8 }, + { 4, 4 } +}; + +int baz(int, int); + +[[gnu::noinline]] void bar(int w, int h) +{ + for (int i = 0; i < w; i++) + for (int j = 0; i < h; j++) + baz (i, j); +} + +void foo (int index) +{ + int w = sizes[index].w; + int h = sizes[index].h; + + bar (w, h); +} +/* { dg-final { scan-ipa-dump "irange" "cp" } } */ diff --git a/gcc/testsuite/gcc.dg/lto/pr122515_0.c b/gcc/testsuite/gcc.dg/lto/pr122515_0.c new file mode 100644 index 0000000..fb2fa8b --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr122515_0.c @@ -0,0 +1,9 @@ +/* { dg-lto-do ar-link } */ +/* { dg-lto-options { { -flto=auto -ffat-lto-objects } } } */ + +extern int bar_7 (int); + +int main (void) +{ + return bar_7 (42); +} diff --git a/gcc/testsuite/gcc.dg/lto/pr122515_1.c b/gcc/testsuite/gcc.dg/lto/pr122515_1.c new file mode 100644 index 0000000..f676c4a --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr122515_1.c @@ -0,0 +1,12 @@ +typedef struct { + int num; + int foo[40000000]; +} A_1; + +A_1 a1_1 = {1}; +A_1 a2_1 = {2}; + +int bar_1 (int i) +{ + return i++; +} diff --git a/gcc/testsuite/gcc.dg/lto/pr122515_2.c b/gcc/testsuite/gcc.dg/lto/pr122515_2.c new file mode 100644 index 0000000..acda878 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr122515_2.c @@ -0,0 +1,12 @@ +typedef struct { + int num; + int foo[40000000]; +} A_2; + +A_2 a1_2 = {1}; +A_2 a2_2 = {2}; + +int bar_2 (int i) +{ + return i++; +} diff --git a/gcc/testsuite/gcc.dg/lto/pr122515_3.c b/gcc/testsuite/gcc.dg/lto/pr122515_3.c new file mode 100644 index 0000000..7223e9f --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr122515_3.c @@ -0,0 +1,12 @@ +typedef struct { + int num; + int foo[40000000]; +} A_3; + +A_3 a1_3 = {1}; +A_3 a2_3 = {2}; + +int bar_3 (int i) +{ + return i++; +} diff --git a/gcc/testsuite/gcc.dg/lto/pr122515_4.c b/gcc/testsuite/gcc.dg/lto/pr122515_4.c new file mode 100644 index 0000000..51754ae --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr122515_4.c @@ -0,0 +1,12 @@ +typedef struct { + int num; + int foo[40000000]; +} A_4; + +A_4 a1_4 = {1}; +A_4 a2_4 = {2}; + +int bar_4 (int i) +{ + return i++; +} diff --git a/gcc/testsuite/gcc.dg/lto/pr122515_5.c b/gcc/testsuite/gcc.dg/lto/pr122515_5.c new file mode 100644 index 0000000..cca1787 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr122515_5.c @@ -0,0 +1,12 @@ +typedef struct { + int num; + int foo[40000000]; +} A_5; + +A_5 a1_5 = {1}; +A_5 a2_5 = {2}; + +int bar_5 (int i) +{ + return i++; +} diff --git a/gcc/testsuite/gcc.dg/lto/pr122515_6.c b/gcc/testsuite/gcc.dg/lto/pr122515_6.c new file mode 100644 index 0000000..98e6213 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr122515_6.c @@ -0,0 +1,12 @@ +typedef struct { + int num; + int foo[40000000]; +} A_6; + +A_6 a1_6 = {1}; +A_6 a2_6 = {2}; + +int bar_6 (int i) +{ + return i++; +} diff --git a/gcc/testsuite/gcc.dg/lto/pr122515_7.c b/gcc/testsuite/gcc.dg/lto/pr122515_7.c new file mode 100644 index 0000000..7f27fff --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr122515_7.c @@ -0,0 +1,12 @@ +typedef struct { + int num; + int foo[40000000]; +} A_7; + +A_7 a1_7 = {1}; +A_7 a2_7 = {2}; + +int bar_7 (int i) +{ + return i++; +} diff --git a/gcc/testsuite/gcc.dg/lto/pr122515_8.c b/gcc/testsuite/gcc.dg/lto/pr122515_8.c new file mode 100644 index 0000000..f3d56bd --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr122515_8.c @@ -0,0 +1,12 @@ +typedef struct { + int num; + int foo[40000000]; +} A_8; + +A_8 a1_8 = {1}; +A_8 a2_8 = {2}; + +int bar_8 (int i) +{ + return i++; +} diff --git a/gcc/testsuite/gcc.dg/lto/pr122515_9.c b/gcc/testsuite/gcc.dg/lto/pr122515_9.c new file mode 100644 index 0000000..2fdd04c --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr122515_9.c @@ -0,0 +1,12 @@ +typedef struct { + int num; + int foo[40000000]; +} A_9; + +A_9 a1_9 = {1}; +A_9 a2_9 = {2}; + +int bar_9 (int i) +{ + return i++; +} diff --git a/gcc/testsuite/gcc.dg/lto/pr122603_0.c b/gcc/testsuite/gcc.dg/lto/pr122603_0.c new file mode 100644 index 0000000..127aeb7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr122603_0.c @@ -0,0 +1,6 @@ +/* PR lto/122603 */ +/* { dg-lto-do link } */ +/* { dg-lto-options { "-O0 -flto -flto-partition=cache --param=lto-min-partition=1" } } */ + +int main() {} +asm(""); diff --git a/gcc/testsuite/gcc.dg/match-shift-cmp-1.c b/gcc/testsuite/gcc.dg/match-shift-cmp-1.c new file mode 100644 index 0000000..7a69cd1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/match-shift-cmp-1.c @@ -0,0 +1,41 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +#define TEST_ONE_CST(n, op, type, cst) \ + bool lshift_cst_##type##_##n (type x) { return (cst << x) op x; } + +#define TEST_OP_CST(n, op, cst) \ + TEST_ONE_CST (n, op, unsigned, cst) \ + TEST_ONE_CST (n, op, int, cst) \ + TEST_ONE_CST (n, op, bool, cst) \ + TEST_ONE_CST (n, op, test_enum, cst) + +#define TEST_ONE(n, op, type) \ + bool lshift_##type##_##n (type x, type y) \ + { \ + if (y <= 0) \ + __builtin_unreachable (); \ + return (y << x) op x; \ + } + +#define TEST_OP(n, op) \ + TEST_ONE (n, op, unsigned) \ + TEST_ONE (n, op, int) \ + TEST_ONE (n, op, bool) \ + TEST_ONE (n, op, test_enum) + +typedef enum +{ + MONE = -1, + ZERO = 0, + ONE = 1, + TWO = 2 +} test_enum; + +TEST_OP_CST (eq, ==, 1) +TEST_OP_CST (ne, !=, 2) + +TEST_OP (eq, ==) +TEST_OP (ne, !=) + +/* { dg-final { scan-tree-dump-not "<<" optimized } } */ diff --git a/gcc/testsuite/gcc.dg/match-shift-cmp-2.c b/gcc/testsuite/gcc.dg/match-shift-cmp-2.c new file mode 100644 index 0000000..3d514ba --- /dev/null +++ b/gcc/testsuite/gcc.dg/match-shift-cmp-2.c @@ -0,0 +1,47 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +/* The fold (y << x) <op> x -> 0|1 shouldn't trigger when y is 0. */ + +#define TEST_ONE_CST(n, op, type, cst) \ + bool lshift_cst_##type##_##n (type x) { return (cst << x) op x; } + +#define TEST_OP_CST(n, op, cst) \ + TEST_ONE_CST (n, op, unsigned, cst) \ + TEST_ONE_CST (n, op, int, cst) \ + TEST_ONE_CST (n, op, bool, cst) \ + TEST_ONE_CST (n, op, test_enum, cst) + +#define TEST_ONE(n, op, type) \ + bool lshift_##type##_##n (type x, type y) \ + { \ + if (y != 0) \ + __builtin_unreachable (); \ + return (y << x) op x; \ + } + +#define TEST_OP(n, op) \ + TEST_ONE (n, op, unsigned) \ + TEST_ONE (n, op, int) \ + TEST_ONE (n, op, bool) \ + TEST_ONE (n, op, test_enum) + +typedef enum +{ + MONE = -1, + ZERO = 0, + ONE = 1, + TWO = 2 +} test_enum; + +TEST_OP_CST (eq, ==, 0) +TEST_OP_CST (ne, !=, 0) + +TEST_OP (eq, ==) +TEST_OP (ne, !=) + +/* These end up getting folded by other patterns. */ +/* { dg-final { scan-tree-dump-times "x_\\d\\(D\\) == 0" 6 optimized } } */ +/* { dg-final { scan-tree-dump-times "x_\\d\\(D\\) != 0" 6 optimized } } */ +/* { dg-final { scan-tree-dump-times "~x_\\d\\(D\\)" 2 optimized } } */ +/* { dg-final { scan-tree-dump-times "return x_\\d\\(D\\);" 2 optimized } } */ diff --git a/gcc/testsuite/gcc.dg/match-shift-cmp-3.c b/gcc/testsuite/gcc.dg/match-shift-cmp-3.c new file mode 100644 index 0000000..e46ac30 --- /dev/null +++ b/gcc/testsuite/gcc.dg/match-shift-cmp-3.c @@ -0,0 +1,43 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +/* The fold (y << x) <op> x -> 0|1 should trigger when y is negative + unsigned. */ + +#define TEST_ONE_CST(n, op, type, cst) \ + bool lshift_cst_##type##_##n (type x) { return ((unsigned) (cst) << x) op x; } + +#define TEST_OP_CST(n, op, cst) \ + TEST_ONE_CST (n, op, unsigned, cst) \ + TEST_ONE_CST (n, op, int, cst) \ + TEST_ONE_CST (n, op, test_enum, cst) + +#define TEST_ONE(n, op, type) \ + bool lshift_##type##_##n (type x, type y) \ + { \ + if ((int) y <= 0) \ + __builtin_unreachable (); \ + return ((unsigned) (y) << x) op x; \ + } + +#define TEST_OP(n, op) \ + TEST_ONE (n, op, unsigned) \ + TEST_ONE (n, op, int) \ + TEST_ONE (n, op, test_enum) + +typedef enum +{ + MONE = -1, + ZERO = 0, + ONE = 1, + TWO = 2 +} test_enum; + +TEST_OP_CST (eq, ==, -1) +TEST_OP_CST (ne, !=, -2) + +TEST_OP (eq, ==) +TEST_OP (ne, !=) + +/* { dg-final { scan-tree-dump-times "return 0;" 6 optimized } } */ +/* { dg-final { scan-tree-dump-times "return 1;" 6 optimized } } */ diff --git a/gcc/testsuite/gcc.dg/match-shift-cmp-4.c b/gcc/testsuite/gcc.dg/match-shift-cmp-4.c new file mode 100644 index 0000000..c2458d9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/match-shift-cmp-4.c @@ -0,0 +1,47 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-times "return 0;" 4 "optimized" { target bitint575 } } } */ +/* { dg-final { scan-tree-dump-times "return 0;" 2 "optimized" { target { ! bitint575 } } } } */ +/* { dg-final { scan-tree-dump-not " << " "optimized" } } */ + +bool +foo (unsigned long long x, unsigned y) +{ + if (x >= 64 || x == 0) + __builtin_unreachable (); + if (y > sizeof (unsigned long long) * __CHAR_BIT__ - 6) + __builtin_unreachable (); + return (x << y) <= y; +} + +#if __BITINT_MAXWIDTH__ >= 575 +bool +bar (unsigned _BitInt(575) x, unsigned y) +{ + if (x >= 1361129467683753853853498429727072845823uwb || x == 0) + __builtin_unreachable (); + if (y > 575 - 130) + __builtin_unreachable (); + return (x << y) < y; +} + +bool +baz (unsigned _BitInt(575) x, unsigned y) +{ + if (x >= 1361129467683753853853498429727072845823uwb || x == 0) + __builtin_unreachable (); + if (y >= 575 - 130) + __builtin_unreachable (); + return ((signed _BitInt(575)) (x << y)) < y; +} +#endif + +bool +qux (int x, int y) +{ + if (x >= 128 || x <= 0) + __builtin_unreachable (); + if (y >= sizeof (int) * __CHAR_BIT__ - 7) + __builtin_unreachable (); + return (x << y) <= y; +} diff --git a/gcc/testsuite/gcc.dg/match-shift-cmp-5.c b/gcc/testsuite/gcc.dg/match-shift-cmp-5.c new file mode 100644 index 0000000..7768f59 --- /dev/null +++ b/gcc/testsuite/gcc.dg/match-shift-cmp-5.c @@ -0,0 +1,47 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-times "return 1;" 4 "optimized" { target bitint575 } } } */ +/* { dg-final { scan-tree-dump-times "return 1;" 2 "optimized" { target { ! bitint575 } } } } */ +/* { dg-final { scan-tree-dump-not " << " "optimized" } } */ + +bool +foo (unsigned long long x, unsigned y) +{ + if (x >= 64 || x == 0) + __builtin_unreachable (); + if (y > sizeof (unsigned long long) * __CHAR_BIT__ - 6) + __builtin_unreachable (); + return (x << y) >= y; +} + +#if __BITINT_MAXWIDTH__ >= 575 +bool +bar (unsigned _BitInt(575) x, unsigned y) +{ + if (x >= 1361129467683753853853498429727072845823uwb || x == 0) + __builtin_unreachable (); + if (y > 575 - 130) + __builtin_unreachable (); + return (x << y) > y; +} + +bool +baz (unsigned _BitInt(575) x, unsigned y) +{ + if (x >= 1361129467683753853853498429727072845823uwb || x == 0) + __builtin_unreachable (); + if (y >= 575 - 130) + __builtin_unreachable (); + return ((signed _BitInt(575)) (x << y)) > y; +} +#endif + +bool +qux (int x, int y) +{ + if (x >= 128 || x <= 0) + __builtin_unreachable (); + if (y >= sizeof (int) * __CHAR_BIT__ - 7) + __builtin_unreachable (); + return (x << y) >= y; +} diff --git a/gcc/testsuite/gcc.dg/maxof-bitint.c b/gcc/testsuite/gcc.dg/maxof-bitint.c new file mode 100644 index 0000000..647909c --- /dev/null +++ b/gcc/testsuite/gcc.dg/maxof-bitint.c @@ -0,0 +1,20 @@ +/* { dg-do compile { target bitint } } */ +/* { dg-options "-std=gnu2y" } */ + +void +limits (void) +{ + _Static_assert (_Maxof (_BitInt (5)) == 15); + _Static_assert (_Minof (_BitInt (5)) == -16); + _Static_assert (_Maxof (unsigned _BitInt (5)) == 31); + _Static_assert (_Minof (unsigned _BitInt (5)) == 0); +} + +void +type (void) +{ + _Generic (_Maxof (_BitInt (5)), _BitInt (5): 0); + _Generic (_Minof (_BitInt (5)), _BitInt (5): 0); + _Generic (_Maxof (unsigned _BitInt (5)), unsigned _BitInt (5): 0); + _Generic (_Minof (unsigned _BitInt (5)), unsigned _BitInt (5): 0); +} diff --git a/gcc/testsuite/gcc.dg/maxof-bitint575.c b/gcc/testsuite/gcc.dg/maxof-bitint575.c new file mode 100644 index 0000000..f43951a --- /dev/null +++ b/gcc/testsuite/gcc.dg/maxof-bitint575.c @@ -0,0 +1,39 @@ +/* { dg-do run { target bitint575 } } */ +/* { dg-options "-std=gnu2y" } */ + +#define assert(e) ((e) ? (void) 0 : __builtin_abort ()) + +void limits (void); + +int +main (void) +{ + limits (); +} + +void +limits (void) +{ + unsigned _BitInt (500) u; + _BitInt (500) i; + + u = 0; + u--; + + assert (_Maxof (unsigned _BitInt (500)) == u); + assert (_Minof (unsigned _BitInt (500)) == 0); + + i = u >> 1; + + assert (_Maxof (_BitInt (500)) == i); + assert (_Minof (_BitInt (500)) == -i-1); +} + +void +type (void) +{ + _Generic (_Maxof (_BitInt (500)), _BitInt (500): 0); + _Generic (_Minof (_BitInt (500)), _BitInt (500): 0); + _Generic (_Maxof (unsigned _BitInt (500)), unsigned _BitInt (500): 0); + _Generic (_Minof (unsigned _BitInt (500)), unsigned _BitInt (500): 0); +} diff --git a/gcc/testsuite/gcc.dg/maxof-compile.c b/gcc/testsuite/gcc.dg/maxof-compile.c new file mode 100644 index 0000000..098cade --- /dev/null +++ b/gcc/testsuite/gcc.dg/maxof-compile.c @@ -0,0 +1,158 @@ +/* { dg-do compile } */ +/* { dg-options "-std=gnu2y" } */ + +#define SCHAR_MAX __SCHAR_MAX__ +#define SCHAR_MIN (-SCHAR_MAX - 1) +#define UCHAR_MAX (SCHAR_MAX * 2 + 1) + +#define SHRT_MAX __SHRT_MAX__ +#define SHRT_MIN (-SHRT_MAX - 1) +#define USHRT_MAX (SHRT_MAX * 2U + 1) + +#define INT_MAX __INT_MAX__ +#define INT_MIN (-INT_MAX - 1) +#define UINT_MAX (INT_MAX * 2U + 1) + +#define LONG_MAX __LONG_MAX__ +#define LONG_MIN (-LONG_MAX - 1L) +#define ULONG_MAX (LONG_MAX * 2LU + 1) + +void +integer (void) +{ + _Static_assert (_Maxof (char) == SCHAR_MAX || _Maxof (char) == UCHAR_MAX); + _Static_assert (_Minof (char) == SCHAR_MIN || _Minof (char) == 0); + + _Static_assert (_Maxof (signed char) == SCHAR_MAX); + _Static_assert (_Maxof (short) == SHRT_MAX); + _Static_assert (_Maxof (int) == INT_MAX); + _Static_assert (_Maxof (long) == LONG_MAX); + _Static_assert (_Maxof (long long) >= LONG_MAX); + + _Static_assert (_Minof (signed char) == SCHAR_MIN); + _Static_assert (_Minof (short) == SHRT_MIN); + _Static_assert (_Minof (int) == INT_MIN); + _Static_assert (_Minof (long) == LONG_MIN); + _Static_assert (_Minof (long long) <= LONG_MIN); + + _Static_assert (_Maxof (unsigned char) == UCHAR_MAX); + _Static_assert (_Maxof (unsigned short) == USHRT_MAX); + _Static_assert (_Maxof (unsigned int) == UINT_MAX); + _Static_assert (_Maxof (unsigned long) == ULONG_MAX); + _Static_assert (_Maxof (unsigned long long) >= ULONG_MAX); + + _Static_assert (_Minof (unsigned char) == 0); + _Static_assert (_Minof (unsigned short) == 0); + _Static_assert (_Minof (unsigned int) == 0); + _Static_assert (_Minof (unsigned long) == 0); + _Static_assert (_Minof (unsigned long long) == 0); + + _Static_assert (_Maxof (bool) == true); + _Static_assert (_Minof (bool) == false); +} + +void +enums (void) +{ + enum e1 { E1 }; + enum e2 : short { E2 }; + + _Maxof (enum e1); + _Minof (enum e1); + _Static_assert (_Maxof (enum e2) == SHRT_MAX); + _Static_assert (_Minof (enum e2) == SHRT_MIN); +} + +void +expr (void) +{ + int x; + + _Maxof (x); /* { dg-error "to something not a type" } */ + /* { dg-error "expected '\\)'" "syntax error" { target *-*-* } .-1 } */ + _Minof (x); /* { dg-error "to something not a type" } */ + /* { dg-error "expected '\\)'" "syntax error" { target *-*-* } .-1 } */ + _Maxof (1); /* { dg-error "to something not a type" } */ + /* { dg-error "expected '\\)'" "syntax error" { target *-*-* } .-1 } */ + _Minof (1); /* { dg-error "to something not a type" } */ + /* { dg-error "expected '\\)'" "syntax error" { target *-*-* } .-1 } */ + _Maxof 1; /* { dg-error "expected '\\('" } */ + _Minof 1; /* { dg-error "expected '\\('" } */ + _Maxof (int) {1}; /* { dg-error "expected ';'" } */ + _Minof (int) {1}; /* { dg-error "expected ';'" } */ +} + +void +incomplete (void) +{ + _Maxof (enum e); /* { dg-error "to incomplete type" } */ + _Minof (enum e); /* { dg-error "to incomplete type" } */ +} + +void +non_int (void) +{ + struct s {int x;}; + union u {int x;}; + + _Maxof (struct s); /* { dg-error "to type" } */ + _Minof (struct s); /* { dg-error "to type" } */ + _Maxof (union u); /* { dg-error "to type" } */ + _Minof (union u); /* { dg-error "to type" } */ + _Maxof (int [1]); /* { dg-error "to type" } */ + _Minof (int [1]); /* { dg-error "to type" } */ +} + +void +specs (void) +{ + _Maxof (static int); /* { dg-error "to something not a type" } */ + /* { dg-error "expected '\\)'" "syntax error" { target *-*-* } .-1 } */ + _Minof (static int); /* { dg-error "to something not a type" } */ + /* { dg-error "expected '\\)'" "syntax error" { target *-*-* } .-1 } */ + _Maxof (alignas(8) int); /* { dg-error "alignment specified" } */ + _Minof (alignas(8) int); /* { dg-error "alignment specified" } */ +} + +void +bogus (void) +{ + _Maxof (int x); /* { dg-error "expected '\\)'" } */ + _Minof (int x); /* { dg-error "expected '\\)'" } */ + _Maxof (int (!)); /* { dg-error "expected '\\)'" } */ + _Minof (int (!)); /* { dg-error "expected '\\)'" } */ +} + +void +type (void) +{ + _Generic (_Maxof (char), char: 0); + _Generic (_Minof (char), char: 0); + + _Generic (_Maxof (signed char), signed char: 0); + _Generic (_Maxof (short), short: 0); + _Generic (_Maxof (int), int: 0); + _Generic (_Maxof (long), long: 0); + _Generic (_Maxof (long long), long long: 0); + + _Generic (_Minof (signed char), signed char: 0); + _Generic (_Minof (short), short: 0); + _Generic (_Minof (int), int: 0); + _Generic (_Minof (long), long: 0); + _Generic (_Minof (long long), long long: 0); + + _Generic (_Maxof (unsigned char), unsigned char: 0); + _Generic (_Maxof (unsigned short), unsigned short: 0); + _Generic (_Maxof (unsigned int), unsigned int: 0); + _Generic (_Maxof (unsigned long), unsigned long: 0); + _Generic (_Maxof (unsigned long long), unsigned long long: 0); + + _Generic (_Minof (unsigned char), unsigned char: 0); + _Generic (_Minof (unsigned short), unsigned short: 0); + _Generic (_Minof (unsigned int), unsigned int: 0); + _Generic (_Minof (unsigned long), unsigned long: 0); + _Generic (_Minof (unsigned long long), unsigned long long: 0); + + _Generic (_Maxof (bool), bool: 0); + _Generic (_Minof (bool), bool: 0); +} diff --git a/gcc/testsuite/gcc.dg/maxof-pedantic-errors.c b/gcc/testsuite/gcc.dg/maxof-pedantic-errors.c new file mode 100644 index 0000000..dcb64bb --- /dev/null +++ b/gcc/testsuite/gcc.dg/maxof-pedantic-errors.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c23 -pedantic-errors" } */ + +int a[_Maxof(char)]; /* { dg-error "ISO C does not support" } */ +int b[1 + _Minof(unsigned char)]; /* { dg-error "ISO C does not support" } */ diff --git a/gcc/testsuite/gcc.dg/maxof-pedantic.c b/gcc/testsuite/gcc.dg/maxof-pedantic.c new file mode 100644 index 0000000..fa2582c --- /dev/null +++ b/gcc/testsuite/gcc.dg/maxof-pedantic.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c23 -pedantic" } */ + +int a[_Maxof(char)]; /* { dg-warning "ISO C does not support" } */ +int b[1 + _Minof(unsigned char)]; /* { dg-warning "ISO C does not support" } */ diff --git a/gcc/testsuite/gcc.dg/pid_t-1.c b/gcc/testsuite/gcc.dg/pid_t-1.c new file mode 100644 index 0000000..f4f3f68 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pid_t-1.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-Wall" } */ +/* { dg-require-fork "" } */ + +/* Compile with -Wall to get a warning if built-in and system pid_t don't + match. */ + +#include <sys/types.h> + +typedef __typeof (__builtin_fork ()) __builtin_pid_t; + +__builtin_pid_t __p_t__; +pid_t *p_t_p; + +void +pt (void) +{ + p_t_p = &__p_t__; +} diff --git a/gcc/testsuite/gcc.dg/plugin/location-overflow-test-3.c b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-3.c new file mode 100644 index 0000000..2acf1c3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-3.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-fplugin-arg-location_overflow_plugin-value=1024 -fdump-internal-locations" } */ + +/* The plugin arranges for location_t values to exceed 32 bits; verify the + internal dump routines don't crash. The exact output depends on the system + and on absolute path names, and this output is only meant for internal + purposes, so don't demand an exact form of the output. */ + +/* { dg-allow-blank-lines-in-output 1 } */ +/* { dg-prune-output ".*" } */ diff --git a/gcc/testsuite/gcc.dg/plugin/plugin.exp b/gcc/testsuite/gcc.dg/plugin/plugin.exp index 38991e8..83ef1b2 100644 --- a/gcc/testsuite/gcc.dg/plugin/plugin.exp +++ b/gcc/testsuite/gcc.dg/plugin/plugin.exp @@ -145,6 +145,7 @@ set plugin_test_list [list \ { location_overflow_plugin.cc \ location-overflow-test-1.c \ location-overflow-test-2.c \ + location-overflow-test-3.c \ location-overflow-test-pr83173.c \ location-overflow-test-pr116047.c \ location-overflow-test-pr120061.c } \ diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-10.c b/gcc/testsuite/gcc.dg/pointer-counted-by-10.c new file mode 100644 index 0000000..e2bd018 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pointer-counted-by-10.c @@ -0,0 +1,8 @@ +/* Testing the correct usage of attribute counted_by for pointer to void. */ +/* { dg-do compile } */ +/* { dg-options "-O0 -Wpointer-arith" } */ + +struct pointer_array { + int count; + void *array __attribute__ ((counted_by (count))); /* { dg-warning "attribute is used for a pointer to void" } */ +}; diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-4-void.c b/gcc/testsuite/gcc.dg/pointer-counted-by-4-void.c new file mode 100644 index 0000000..71bac95 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pointer-counted-by-4-void.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 void +#include "pointer-counted-by-4.c" diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by-pr122982.c b/gcc/testsuite/gcc.dg/pointer-counted-by-pr122982.c new file mode 100644 index 0000000..1bad7f0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pointer-counted-by-pr122982.c @@ -0,0 +1,19 @@ +/* PR c/122982 */ +/* { dg-do compile } */ +/* { dg-options "-O0" } */ + +int* f (int); + +struct __bounded_ptr { + int k; + int *buf __attribute__ ((counted_by (k))); +}; + +int* +f1 (int n) { return f (n); } + +void h1 (void) +{ + int *p = (struct __bounded_ptr) {3, f1 (3)}.buf; + __builtin_memset (p, 0, 3 * sizeof p); +} diff --git a/gcc/testsuite/gcc.dg/pointer-counted-by.c b/gcc/testsuite/gcc.dg/pointer-counted-by.c index 0f18828..5e9ebef 100644 --- a/gcc/testsuite/gcc.dg/pointer-counted-by.c +++ b/gcc/testsuite/gcc.dg/pointer-counted-by.c @@ -49,9 +49,10 @@ struct pointer_array_6 { int *array_6 __attribute__ ((counted_by (days))); }; +/* counted_by is allowed for pointer to void when GNU extension is enabled. */ struct pointer_array_7 { int count; - void *array_7 __attribute__ ((counted_by (count))); /* { dg-error "attribute is not allowed for a pointer to void" } */ + void *array_7 __attribute__ ((counted_by (count))); }; struct pointer_array_8 { diff --git a/gcc/testsuite/gcc.dg/pr102983.c b/gcc/testsuite/gcc.dg/pr102983.c index ded748a..1b0e5c7 100644 --- a/gcc/testsuite/gcc.dg/pr102983.c +++ b/gcc/testsuite/gcc.dg/pr102983.c @@ -18,4 +18,4 @@ int main() { } } -/* { dg-final { scan-tree-dump-times "Global Exported: c_.*1, 1" 1 "evrp" } } */ +/* { dg-final { scan-tree-dump-not "if \\(c_" "evrp" } } */ diff --git a/gcc/testsuite/gcc.dg/pr113632.c b/gcc/testsuite/gcc.dg/pr113632.c new file mode 100644 index 0000000..dd49b66 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr113632.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-evrp" } */ + +void dummy(void); +_Bool f(unsigned long a) +{ + _Bool cmp = a > 8192; + if (cmp) goto then; else goto e; +then: + unsigned long t = __builtin_clzl(a); // [0,50] + t^=63; // [13,63] + if (t < 13 || t >63) + dummy (); +e: + return 0; +} + +void f2(int x) +{ + if (x <= 0 || x == 2 || x == 4 || x == 6) + return; + /* x = [1, 1][3, 3][5, 5][7, 2147483647] */ + /* x ^ 6 should be non-zero. */ + if ((x ^ 6) == 0) + dummy (); +} + +/* { dg-final { scan-tree-dump-not "dummy" "evrp" } } */ diff --git a/gcc/testsuite/gcc.dg/pr116815.c b/gcc/testsuite/gcc.dg/pr116815.c new file mode 100644 index 0000000..7b0650f --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr116815.c @@ -0,0 +1,57 @@ +/* PR target/116815 */ +/* { dg-do run { target int32 } } */ +/* { dg-options "-O2" } */ + +[[gnu::always_inline]] +inline unsigned min (unsigned a, unsigned b) +{ + return (a < b) ? a : b; +} + +[[gnu::always_inline]] +inline unsigned max (unsigned a, unsigned b) +{ + return (a > b) ? a : b; +} + +[[gnu::noipa]] unsigned +umaxadd (unsigned a, unsigned b) +{ + return max (a + b, a); +} + +[[gnu::noipa]] unsigned +umaxsub (unsigned a, unsigned b) +{ + return max (a - b, a); +} + +[[gnu::noipa]] unsigned +uminadd (unsigned a, unsigned b) +{ + return min (a + b, a); +} + +[[gnu::noipa]] unsigned +uminsub (unsigned a, unsigned b) +{ + return min (a - b, a); +} + +int +main () +{ + /* Overflows to 0x30000000. */ + if (umaxadd (0x90000000, 0xa0000000) != 0x90000000) + __builtin_abort (); + + if (uminadd (0x90000000, 0xa0000000) != 0x30000000) + __builtin_abort (); + + /* Underflows to 0x60000000. */ + if (umaxsub (0x00000000, 0xa0000000) != 0x60000000) + __builtin_abort (); + + if (uminsub (0x00000000, 0xa0000000) != 0x00000000) + __builtin_abort (); +} diff --git a/gcc/testsuite/gcc.dg/pr121506.c b/gcc/testsuite/gcc.dg/pr121506.c new file mode 100644 index 0000000..0d06647 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr121506.c @@ -0,0 +1,8 @@ +/* PR c/121506 */ +/* { dg-do compile } */ + +#include <stdarg.h> + +struct A; +void foo (struct A *); /* { dg-message "previous declaration of 'foo' with type 'void\\\(struct A \\\*\\\)'" } */ +void foo (va_list); /* { dg-error "conflicting types for 'foo'; have" } */ diff --git a/gcc/testsuite/gcc.dg/pr121519.c b/gcc/testsuite/gcc.dg/pr121519.c new file mode 100644 index 0000000..e86f67d --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr121519.c @@ -0,0 +1,41 @@ +/* PR tree-optimization/121519 */ +/* { dg-do compile { target int32plus } } */ +/* { dg-options "-O3" } */ + +extern int foo (void); +int a, b, c; + +int +bar (int f) +{ + int d = 0; + for (; d < 6; d++) + { + a = f <<= 1; + if (f & 64) + f ^= 67; + } + return a; +} + +void +baz (void) +{ + int i = 0; + if (c) + goto j; + i = -32644994; +k: + b = 0; +j: + if (foo () - 508050053 + bar (i + 79)) + goto k; +} + +int +main () +{ + while (a) + baz (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/pr122126_vextr.c b/gcc/testsuite/gcc.dg/pr122126_vextr.c new file mode 100644 index 0000000..b598aa0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr122126_vextr.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-mavx2" { target avx2 } } */ + +#define vect16 __attribute__((vector_size(16))) +void ub_set() { + volatile vect16 unsigned BS_VAR_0; + unsigned a = BS_VAR_0[12]; +} diff --git a/gcc/testsuite/gcc.dg/pr122126_vset.c b/gcc/testsuite/gcc.dg/pr122126_vset.c new file mode 100644 index 0000000..85b2c68 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr122126_vset.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-mavx2" { target avx2 } } */ + +#define vect16 __attribute__((vector_size(16))) +void ub_set() { + volatile vect16 unsigned BS_VAR_0; + BS_VAR_0[12] = 4; +} diff --git a/gcc/testsuite/gcc.dg/pr122756.c b/gcc/testsuite/gcc.dg/pr122756.c new file mode 100644 index 0000000..6299469 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr122756.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-additional-options "-march=rv64gcv -mabi=lp64d" { target { rv64 } } } */ + +long a; +void b() { + unsigned long c, d; + for (;; c = d + 2000) { + d = c; + for (; d < a; d += 2) + if (d % 2) + for (;;) + ; + } +} diff --git a/gcc/testsuite/gcc.dg/pr122773.c b/gcc/testsuite/gcc.dg/pr122773.c new file mode 100644 index 0000000..a3860e9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr122773.c @@ -0,0 +1,25 @@ +/* PR middle-end/122773 */ +/* { dg-do compile } */ +/* { dg-options "-Wimplicit-fallthrough -O2 -ftrivial-auto-var-init=zero" } */ + +void *l; +int +foo (int x) +{ + __label__ l1, l2, l3; + static void *l[] = { &&l1, &&l2, &&l3 }; + switch (0) + { + case 0: + while (0) + ; + goto *l[x]; + } + l1: + ++x; + l2: + ++x; + l3: + ++x; + return x; +} diff --git a/gcc/testsuite/gcc.dg/pr122898.c b/gcc/testsuite/gcc.dg/pr122898.c new file mode 100644 index 0000000..8b89c82 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr122898.c @@ -0,0 +1,56 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-tree-forwprop -fno-tree-fre" } */ +extern void o(); +int a, b, c, d, e, f, g, h, i, k, l, m, n; +volatile int j; +static void p() { + if (d) { + q: + if (a) { + if (k) { + if (!(d && e)) + goto r; + if (i) + goto q; + o(); + } + h || j; + } + s: + d || j; + if (a) + goto q; + r: + if (b) { + if (c) + goto t; + if (b) + goto r; + if (m) + goto q; + } + while (j) + ; + u: + if (g) { + o(); + goto s; + } + if (h) { + t: + if (n) + goto v; + o(); + goto r; + } + int w = i & 1; + v: + if (w <= l) + if (f) + goto u; + goto q; + } + if (a) + goto v; +} +int main() { p(); } diff --git a/gcc/testsuite/gcc.dg/pr122947.c b/gcc/testsuite/gcc.dg/pr122947.c new file mode 100644 index 0000000..945a61a --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr122947.c @@ -0,0 +1,45 @@ +/* PR rtl-optimization/122947 based on PR 117239 */ +/* { dg-do run } */ +/* { dg-options "-fno-inline -O2" } */ +/* { dg-additional-options "-fschedule-insns -mno-accumulate-outgoing-args" { target x86 } } */ + +int c = 1; + +struct A { + int e, f, g, h; + short i; + int j; +}; + +void +bar (int x, struct A y) +{ + if (y.j == 1) + c = 0; +} + +/* Simplest pure way to force baz's x.j back to memory. + So simple that IPA "inlines" it, so we disable IPA and mark as pure. */ +int __attribute__ ((noipa, pure)) +bad (struct A const *x) +{ + return x->j; +} + +int +baz (struct A x) +{ + x.j = 0; + return bad (&x); +} + +int +main () +{ + struct A k = { 0, 0, 0, 0, 0, 1 }; + int d = baz (k); + bar (0, k); + if (c + d != 0) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/pr122991.c b/gcc/testsuite/gcc.dg/pr122991.c new file mode 100644 index 0000000..6b27a2d --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr122991.c @@ -0,0 +1,28 @@ +/* PR target/122991 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-additional-options "-msse4" { target i?86-*-* x86_64-*-* } } */ + +int +foo () +{ + return __builtin_rev_crc32_data32 (0, 0, 0); +} + +int +bar () +{ + return __builtin_rev_crc32_data32 (-1U, -1U, -1U); +} + +int +baz () +{ + return __builtin_crc32_data32 (0, 0, 0); +} + +int +qux () +{ + return __builtin_crc32_data32 (-1U, -1U, -1U); +} diff --git a/gcc/testsuite/gcc.dg/pr123018.c b/gcc/testsuite/gcc.dg/pr123018.c new file mode 100644 index 0000000..f1f701b --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr123018.c @@ -0,0 +1,17 @@ +/* PR c/123018 */ +/* { dg-do compile } */ + +struct A { + int x : 8 __attribute__ ((vector_size (8))); /* { dg-error "bit-field 'x' has invalid type" } */ +}; +struct B { + float x : 8; /* { dg-error "bit-field 'x' has invalid type" } */ +}; +struct C { + int : 8 __attribute__ ((vector_size (8))); /* { dg-error "bit-field '\[^\n\r]*anonymous\[^\n\r]*' has invalid type" } */ + int x; +}; +struct D { + float : 8; /* { dg-error "bit-field '\[^\n\r]*anonymous\[^\n\r]*' has invalid type" } */ + int x; +}; diff --git a/gcc/testsuite/gcc.dg/pr41488.c b/gcc/testsuite/gcc.dg/pr41488.c index 1e4bf19..a7ba367 100644 --- a/gcc/testsuite/gcc.dg/pr41488.c +++ b/gcc/testsuite/gcc.dg/pr41488.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-ivcanon-scev" } */ +/* { dg-options "-O2 -fno-tree-scev-cprop -fdump-tree-ivcanon-scev" } */ struct struct_t { diff --git a/gcc/testsuite/gcc.dg/pr68090.c b/gcc/testsuite/gcc.dg/pr68090.c index 87b3b93..84e0ca4 100644 --- a/gcc/testsuite/gcc.dg/pr68090.c +++ b/gcc/testsuite/gcc.dg/pr68090.c @@ -1,13 +1,18 @@ /* PR c/68090 */ /* { dg-do compile } */ -/* { dg-options "" } */ +/* { dg-options "--pedantic-error" } */ void fn (int i) { (int[(0, 1)]) { 0 }; /* { dg-error "compound literal has variable size" } */ + /* { dg-error "variable-size" "" { target *-*-* } .-1 } */ (int[i]) { 0 }; /* { dg-error "compound literal has variable size" } */ + /* { dg-error "variable-size" "" { target *-*-* } .-1 } */ (int[(0, i)]) { 0 }; /* { dg-error "compound literal has variable size" } */ + /* { dg-error "variable-size" "" { target *-*-* } .-1 } */ (int [][i]){ 0 }; /* { dg-error "compound literal has variable size" } */ + /* { dg-error "variable-size" "" { target *-*-* } .-1 } */ (int [][(1, 2)]){ 0 }; /* { dg-error "compound literal has variable size" } */ + /* { dg-error "variable-size" "" { target *-*-* } .-1 } */ } diff --git a/gcc/testsuite/gcc.dg/pr90838.c b/gcc/testsuite/gcc.dg/pr90838.c index 9a330f7..8b06929 100644 --- a/gcc/testsuite/gcc.dg/pr90838.c +++ b/gcc/testsuite/gcc.dg/pr90838.c @@ -60,13 +60,13 @@ int ctz4 (unsigned long x) return table[(lsb * magic) >> 58]; } -/* { dg-final { scan-tree-dump-times {= \.CTZ} 4 "forwprop2" { target { { i?86-*-* x86_64-*-* } && { ! { ia32 } } } } } } */ -/* { dg-final { scan-assembler-times "tzcntq\t" 1 { target { { i?86-*-* x86_64-*-* } && { ! { ia32 } } } } } } */ +/* { dg-final { scan-tree-dump-times {= \.CTZ} 4 "forwprop2" { target { { i?86-*-* x86_64-*-* } && lp64 } } } } */ +/* { dg-final { scan-assembler-times "tzcntq\t" 1 { target { { i?86-*-* x86_64-*-* } && lp64 } } } } */ /* { dg-final { scan-assembler-times "tzcntl\t" 3 { target { { i?86-*-* x86_64-*-* } && { ! { ia32 } } } } } } */ -/* { dg-final { scan-assembler-times "andl\t" 2 { target { { i?86-*-* x86_64-*-* } && { ! { ia32 } } } } } } */ +/* { dg-final { scan-assembler-times "andl\t" 2 { target { { i?86-*-* x86_64-*-* } && lp64 } } } } */ /* { dg-final { scan-assembler-not "negq" { target { { i?86-*-* x86_64-*-* } && { ! { ia32 } } } } } } */ -/* { dg-final { scan-assembler-not "imulq" { target { { i?86-*-* x86_64-*-* } && { ! { ia32 } } } } } } */ -/* { dg-final { scan-assembler-not "shrq" { target { { i?86-*-* x86_64-*-* } && { ! { ia32 } } } } } } */ +/* { dg-final { scan-assembler-not "imulq" { target { { i?86-*-* x86_64-*-* } && { ! { x32 } } } } } } */ +/* { dg-final { scan-assembler-not "shrq" { target { { i?86-*-* x86_64-*-* } && { ! { x32 } } } } } } */ /* { dg-final { scan-tree-dump-times {= \.CTZ} 4 "forwprop2" { target aarch64*-*-* } } } */ /* { dg-final { scan-assembler-times "clz\t" 4 { target aarch64*-*-* } } } */ diff --git a/gcc/testsuite/gcc.dg/pr91191.c b/gcc/testsuite/gcc.dg/pr91191.c new file mode 100644 index 0000000..7bf727e --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr91191.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-evrp" } */ + +unsigned char reg(_Bool b) { + union U { + unsigned char f0; + _Bool f1; + }; + union U u; + u.f1 = b; + if (u.f0 > 1) { + // This cannot happen + // if b is only allowed + // to be 0 or 1: + return 42; + } + return 13; +} + +/* { dg-final { scan-tree-dump "return 13" "evrp" } } */ diff --git a/gcc/testsuite/gcc.dg/pr97986-1.c b/gcc/testsuite/gcc.dg/pr97986-1.c new file mode 100644 index 0000000..87ee3d8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr97986-1.c @@ -0,0 +1,27 @@ +/* { dg-do run } */ +/* { dg-options "-std=gnu23" } */ + +#include <stdarg.h> + +int f(int n, ...) +{ + __label__ b, d; + va_list ap; + va_start(ap, n); + _Static_assert(5 == sizeof(va_arg(ap, char[5]))); /* { dg-warning "array type" } */ + void g(void) { n++; goto b; } + int *a = va_arg((g(), ap), int[n]); /* { dg-warning "array type" } */ +b: + void h(void) { n++; goto d; } + typeof(va_arg(ap, int[(h(), n)])) c; /* { dg-warning "array type" } */ +d: + return n; +} + +int main() +{ + if (9 != f(7)) + __builtin_abort(); + return 0; +} + diff --git a/gcc/testsuite/gcc.dg/pr97986-2.c b/gcc/testsuite/gcc.dg/pr97986-2.c new file mode 100644 index 0000000..fc23a57 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr97986-2.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c90" } */ + +#include <stdarg.h> + + +int f(int n, ...) +{ + va_list ap; + va_start(ap, n); + _Static_assert(5 == sizeof(va_arg(ap, char[5]))); + va_arg(ap, int[n]); /* { dg-error "array type" } */ + int * a = va_arg(ap, int[3]); /* { dg-error "invalid use of non-lvalue array" } */ +} + diff --git a/gcc/testsuite/gcc.dg/tls/data-sections-1.c b/gcc/testsuite/gcc.dg/tls/data-sections-1.c new file mode 100644 index 0000000..c829256 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tls/data-sections-1.c @@ -0,0 +1,14 @@ +/* { dg-do run } */ +/* { dg-require-effective-target tls_runtime } */ +/* { dg-options "-fdata-sections" } */ +/* { dg-add-options tls } */ + +__thread int i = 1; + +int main (void) +{ + if (i != 1) + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr113026-1.c b/gcc/testsuite/gcc.dg/torture/pr113026-1.c index 56dfef3..37b5281d 100644 --- a/gcc/testsuite/gcc.dg/torture/pr113026-1.c +++ b/gcc/testsuite/gcc.dg/torture/pr113026-1.c @@ -1,4 +1,6 @@ -/* { dg-do compile } */ +/* { dg-do compile } */ +/* When tracing the vector epilog we diagnose an unreachable access. */ +/* { dg-skip-if "" { *-*-* } { "-ftracer" } { "" } } */ /* { dg-additional-options "-Wall" } */ char dst[16]; diff --git a/gcc/testsuite/gcc.dg/torture/pr116835.c b/gcc/testsuite/gcc.dg/torture/pr116835.c new file mode 100644 index 0000000..31d3b59 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr116835.c @@ -0,0 +1,33 @@ +/* { dg-do run { target { weak_undefined } } } */ +/* { dg-add-options weak_undefined } */ + +/* PR tree-optimization/116835 */ +/* phiprop would prop into the loop the load of b + and also prop the load of a before the loop. + Which is incorrect as a is a weak symbol. */ + +struct s1 +{ + int t; + int t1; +}; +typedef struct s1 type; +extern type a __attribute__((weak)); +int t; +type b; +type bar (int c) __attribute__((noipa, noinline)); +type +bar (int c) +{ + t = 1; + type *p = &a; + for (int j = 0; j < c; ++j) + p = &b; + return *p; +} + +int main(void) +{ + if (bar(&a == nullptr).t) + __builtin_abort(); +} diff --git a/gcc/testsuite/gcc.dg/torture/pr122497-1.c b/gcc/testsuite/gcc.dg/torture/pr122497-1.c new file mode 100644 index 0000000..8b027ca --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr122497-1.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* PR tree-optimization/122497 */ + +/* This was ICEing during SCCP + trying to simplify a reference back to the phi + which was removed. */ + +char g_2[1][2]; +int g_4, g_5; +void main() { + for (; g_4; g_4 -= 1) + g_5 = g_2[g_4 + 2][g_4]; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr122502-2.c b/gcc/testsuite/gcc.dg/torture/pr122502-2.c new file mode 100644 index 0000000..36a114d --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr122502-2.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ + +typedef struct { + int mant; + int exp; +} SoftFloat; +SoftFloat __trans_tmp_8, main___trans_tmp_5; +static SoftFloat av_normalize_sf(SoftFloat a) { + while (a.mant + 536870911 < 1073741823) { + a.mant += a.mant; + a.exp -= 1; + } + return a; +} +void main() { + main___trans_tmp_5 = av_normalize_sf((SoftFloat){1, 29 + 1}); + SoftFloat sf1 = main___trans_tmp_5; + for (;;) { + int t = main___trans_tmp_5.exp - sf1.exp; + if (t < 2) + sf1 = __trans_tmp_8; + } +} diff --git a/gcc/testsuite/gcc.dg/torture/pr122502.c b/gcc/testsuite/gcc.dg/torture/pr122502.c new file mode 100644 index 0000000..5e2cb2e --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr122502.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ + +short int *ts; + +void +c2 (unsigned long long int s4, int ns) +{ + short int *b2 = (short int *)&ns; + + while (ns != 0) + { + int xn; + + for (xn = 0; xn < 3; ++xn) + for (*b2 = 0; *b2 < 2; ++*b2) + s4 += xn; + if (s4 != 0) + b2 = ts; + ++ns; + } +} diff --git a/gcc/testsuite/gcc.dg/torture/pr122599-1.c b/gcc/testsuite/gcc.dg/torture/pr122599-1.c new file mode 100644 index 0000000..5f2356f --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr122599-1.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ +/* PR tree-optimization/122599 */ + +void f(int *x, unsigned n) { + for (int i = 0; i < 5; i++) + while ((int)--n >= 0) + x[0] = 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr122615.c b/gcc/testsuite/gcc.dg/torture/pr122615.c new file mode 100644 index 0000000..9f4f3c4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr122615.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-original" } */ +/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */ + +int f1 (int x) +{ + return x & 1 ? (x & ~1) : (x | 1); +} + +int f2 (int x) +{ + return x & 2 ? (x & ~2) : (x | 2); +} + +int f3 (int x) +{ + return x & 3 ? (x & ~3) : (x | 3); +} + +/* { dg-final { scan-tree-dump-times "x \\^ 1" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "x \\^ 2" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "x \\^ 3" 0 "original" } } */ diff --git a/gcc/testsuite/gcc.dg/torture/pr122616.c b/gcc/testsuite/gcc.dg/torture/pr122616.c new file mode 100644 index 0000000..77d364e --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr122616.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-original" } */ +/* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */ + +int f1 (int x) +{ + return x & 1 ? (x - 1) : (x | 1); +} + +int f2 (int x) +{ + return x & 2 ? (x - 2) : (x | 2); +} + +int f3 (int x) +{ + return x & 3 ? (x - 3) : (x | 3); +} + +/* { dg-final { scan-tree-dump-times "x \\^ 1" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "x \\^ 2" 1 "original" } } */ +/* { dg-final { scan-tree-dump-times "x \\^ 3" 0 "original" } } */ diff --git a/gcc/testsuite/gcc.dg/torture/pr122629-1.c b/gcc/testsuite/gcc.dg/torture/pr122629-1.c new file mode 100644 index 0000000..47936e7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr122629-1.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* PR tree-optimization/122629 */ + +/* factor_out_operators was factoring out BIT_FIELD_REF and BIT_INSERT_EXPR, + both which requires constant operands so it would not valid to factor. */ + +typedef int ix4 __attribute__((vector_size(4*sizeof(int)))); + +int f(ix4 *a, int l, int *b) +{ + for (int i =0 ;i < l; i++) + { + int t; + ix4 tt = a[i]; + if(*b) t = tt[1]; else t = tt[0]; + *b = t; + } +} + +int g(ix4 *a, int l, int *b) +{ + for (int i =0 ;i < l; i++) + { + ix4 tt = a[i]; + if(*b) tt[1] = 1; else tt[0] = 1; + *a = tt; + } +} diff --git a/gcc/testsuite/gcc.dg/torture/pr122629-2.c b/gcc/testsuite/gcc.dg/torture/pr122629-2.c new file mode 100644 index 0000000..1ade7b9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr122629-2.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* PR tree-optimization/122629 */ + +typedef int ix4 __attribute__((vector_size(4*sizeof(int)))); + +int f(ix4 *a, int l, int *b, ix4 *c) +{ + for (int i =0 ;i < l; i++) + { + int t; + ix4 tt = a[i]; + ix4 tt1 = c[i]; + if(*b) t = tt1[0]; else t = tt[0]; + *b = t; + } +} + +int g(ix4 *a, int l, int *b, ix4 *c) +{ + for (int i =0 ;i < l; i++) + { + ix4 tt = a[i]; + ix4 tt1 = c[i]; + if(*b) { + tt = tt1; + tt[0] = 1; + } else { + tt[0] = 1; + } + a[i] = tt; + } +} diff --git a/gcc/testsuite/gcc.dg/torture/pr122637-1.c b/gcc/testsuite/gcc.dg/torture/pr122637-1.c new file mode 100644 index 0000000..22d6d2d --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr122637-1.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* PR tree-optimization/122637 */ + +char a[10][3]; +int b; +void e(short c) { + for (; c; c--) { + for (int d = 2; d; d--) + b = a[d][0] & a[c][d]; + } +} diff --git a/gcc/testsuite/gcc.dg/torture/pr122701.c b/gcc/testsuite/gcc.dg/torture/pr122701.c new file mode 100644 index 0000000..62d3e3d --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr122701.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ + +char _strtoimax_r_c; +void _strtoimax_r() { + for (;; _strtoimax_r_c++) { + if (_strtoimax_r_c <= '9') + _strtoimax_r_c -= '0'; + if (_strtoimax_r_c >= 'A') + break; + } +} diff --git a/gcc/testsuite/gcc.dg/torture/pr122735.c b/gcc/testsuite/gcc.dg/torture/pr122735.c new file mode 100644 index 0000000..9499ce4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr122735.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ +int a; +void b() { + int c; + unsigned d = c + 19; + a = d >> 32 + 19 + d + 255 - 293; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr122835.c b/gcc/testsuite/gcc.dg/torture/pr122835.c new file mode 100644 index 0000000..03efdfa --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr122835.c @@ -0,0 +1,79 @@ +/* PR middle-end/122835 */ +/* { dg-do run { target i?86-*-* x86_64-*-* aarch64-*-* arm*-*-* powerpc*-*-* s390*-*-* } } */ + +#if defined(__x86_64__) || defined(__i386__) +#define JMP "jmp" +#elif defined(__aarch64__) || defined(__arm__) || defined(__powerpc__) +#define JMP "b" +#elif defined(__s390__) +#define JMP "j" +#endif + +int cnt; + +static void +my_cleanup (int *p) +{ + ++cnt; +} + +__attribute__((noipa)) static void +my_abort (void) +{ + __builtin_abort (); +} + +int +main () +{ + { + int x __attribute__((cleanup (my_cleanup))) = 0; + + asm goto (JMP "\t%l0" :::: l1); + + my_abort (); + } + +l1: + if (cnt != 1) + __builtin_abort (); + + { + int x __attribute__((cleanup (my_cleanup))) = 0; + + { + int y __attribute__((cleanup (my_cleanup))) = 0; + + asm goto (JMP "\t%l1" :::: l2, l3); + + my_abort (); + } +l2: + __builtin_abort (); + } +l3: + if (cnt != 3) + __builtin_abort (); + + { + int x __attribute__((cleanup (my_cleanup))) = 0; + + { + int y __attribute__((cleanup (my_cleanup))) = 0; + + asm goto (JMP "\t%l0" :::: l4, l5); + + my_abort (); + } +l4: + if (cnt != 4) + __builtin_abort (); + } + if (0) + { +l5: + __builtin_abort (); + } + if (cnt != 5) + __builtin_abort (); +} diff --git a/gcc/testsuite/gcc.dg/torture/pr122847-1.c b/gcc/testsuite/gcc.dg/torture/pr122847-1.c new file mode 100644 index 0000000..9ec4360 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr122847-1.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* PR tree-optimization/122847 */ + +struct { + char x[6]; +} *a, b; + +int c; + +int d() { + /* `a->x` might trap. */ + char *p = a ? a->x : b.x; + char e = *p; + if (c) + return *(short *)p & e; + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr122873.c b/gcc/testsuite/gcc.dg/torture/pr122873.c new file mode 100644 index 0000000..1eadcee --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr122873.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-march=armv9-a -msve-vector-bits=128" { target { aarch64-*-* } } } */ +/* { dg-additional-options "-mavx512bw -mavx512vl --param vect-partial-vector-usage=1" { target { avx512bw && avx512vl } } } */ + +char *b; +bool c(int l) +{ + bool d = true; + for (int a = 0; a < l; a++) + if (b[a]) + d = false; + return d; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr123027.c b/gcc/testsuite/gcc.dg/torture/pr123027.c new file mode 100644 index 0000000..cba4cc9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr123027.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-options "-ffinite-math-only" } */ +/* { dg-add-options ieee } */ + +double a = 0.0; +double b = -0.0; + +int main() +{ + double min1 = a < b ? a : b; + double max1 = a > b ? a : b; + double min2 = b < a ? b : a; + double max2 = b > a ? b : a; + if (__builtin_copysign (1., min1) != -1. + || __builtin_copysign (1., max1) != -1. + || __builtin_copysign (1., min2) != 1. + || __builtin_copysign (1., max2) != 1.) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr28814.c b/gcc/testsuite/gcc.dg/torture/pr28814.c index cf641ca..e835ff5 100644 --- a/gcc/testsuite/gcc.dg/torture/pr28814.c +++ b/gcc/testsuite/gcc.dg/torture/pr28814.c @@ -1,4 +1,5 @@ /* { dg-do compile { target { ilp32 || lp64 } } } */ +/* { dg-options "-Wno-psabi" { target { riscv*-*-* } } } */ struct w49 { diff --git a/gcc/testsuite/gcc.dg/torture/pr99782-1.c b/gcc/testsuite/gcc.dg/torture/pr99782-1.c new file mode 100644 index 0000000..45fb93e --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr99782-1.c @@ -0,0 +1,17 @@ +/* PR middle-end/99782 */ +/* { dg-do compile { target int128 } } */ +/* { dg-additional-options "-mapxf" { target { { i?86-*-* x86_64-*-* } && { ! ia32 } } } } */ + +int hb; + +void +w4 (__int128 uv, int ng) +{ + int vh; + + for (vh = 0; vh < 14; ++vh) + { + ++ng; + hb = (hb == uv) && ng; + } +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/bit_op_cvt.1.c b/gcc/testsuite/gcc.dg/tree-ssa/bit_op_cvt.1.c new file mode 100644 index 0000000..c0da601 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/bit_op_cvt.1.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +#include "bit_op_cvt.h" + +DEF_BIT_CVT_0(uint8_t, int8_t, uint16_t, |, bit_ior) +DEF_BIT_CVT_0(uint8_t, int8_t, uint32_t, |, bit_ior) +DEF_BIT_CVT_0(uint8_t, int8_t, uint64_t, |, bit_ior) +DEF_BIT_CVT_0(uint8_t, uint8_t, uint16_t, |, bit_ior) +DEF_BIT_CVT_0(uint8_t, uint8_t, uint32_t, |, bit_ior) +DEF_BIT_CVT_0(uint8_t, uint8_t, uint64_t, |, bit_ior) +DEF_BIT_CVT_0(uint8_t, uint8_t, int16_t, |, bit_ior) +DEF_BIT_CVT_0(uint8_t, uint8_t, int32_t, |, bit_ior) +DEF_BIT_CVT_0(uint8_t, uint8_t, int64_t, |, bit_ior) +DEF_BIT_CVT_0(uint8_t, int8_t, int16_t, |, bit_ior) +DEF_BIT_CVT_0(uint8_t, int8_t, int32_t, |, bit_ior) +DEF_BIT_CVT_0(uint8_t, int8_t, int64_t, |, bit_ior) + +DEF_BIT_CVT_0(uint16_t, int16_t, uint32_t, |, bit_ior) +DEF_BIT_CVT_0(uint16_t, int16_t, uint64_t, |, bit_ior) +DEF_BIT_CVT_0(uint16_t, int16_t, int32_t, |, bit_ior) +DEF_BIT_CVT_0(uint16_t, int16_t, int64_t, |, bit_ior) +DEF_BIT_CVT_0(uint16_t, uint16_t, uint32_t, |, bit_ior) +DEF_BIT_CVT_0(uint16_t, uint16_t, uint64_t, |, bit_ior) +DEF_BIT_CVT_0(uint16_t, uint16_t, int32_t, |, bit_ior) +DEF_BIT_CVT_0(uint16_t, uint16_t, int64_t, |, bit_ior) + +DEF_BIT_CVT_0(uint32_t, int32_t, uint64_t, |, bit_ior) +DEF_BIT_CVT_0(uint32_t, int32_t, int64_t, |, bit_ior) +DEF_BIT_CVT_0(uint32_t, uint32_t, uint64_t, |, bit_ior) +DEF_BIT_CVT_0(uint32_t, uint32_t, int64_t, |, bit_ior) + +/* { dg-final { scan-tree-dump-not "_\[0-9]\+ = \\(u?int\[0-9]\+_t\\) _\[0-9]\+;\\s+return _\[0-9]\+;" "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/bit_op_cvt.2.c b/gcc/testsuite/gcc.dg/tree-ssa/bit_op_cvt.2.c new file mode 100644 index 0000000..38671d2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/bit_op_cvt.2.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +#include "bit_op_cvt.h" + +DEF_BIT_CVT_0(int8_t, int8_t, uint16_t, |, bit_ior) +DEF_BIT_CVT_0(int8_t, int8_t, uint32_t, |, bit_ior) +DEF_BIT_CVT_0(int8_t, int8_t, uint64_t, |, bit_ior) +DEF_BIT_CVT_0(int8_t, uint8_t, uint16_t, |, bit_ior) +DEF_BIT_CVT_0(int8_t, uint8_t, uint32_t, |, bit_ior) +DEF_BIT_CVT_0(int8_t, uint8_t, uint64_t, |, bit_ior) +DEF_BIT_CVT_0(int8_t, uint8_t, int16_t, |, bit_ior) +DEF_BIT_CVT_0(int8_t, uint8_t, int32_t, |, bit_ior) +DEF_BIT_CVT_0(int8_t, uint8_t, int64_t, |, bit_ior) +DEF_BIT_CVT_0(int8_t, int8_t, int16_t, |, bit_ior) +DEF_BIT_CVT_0(int8_t, int8_t, int32_t, |, bit_ior) +DEF_BIT_CVT_0(int8_t, int8_t, int64_t, |, bit_ior) + +DEF_BIT_CVT_0(int16_t, int16_t, uint32_t, |, bit_ior) +DEF_BIT_CVT_0(int16_t, int16_t, uint64_t, |, bit_ior) +DEF_BIT_CVT_0(int16_t, int16_t, int32_t, |, bit_ior) +DEF_BIT_CVT_0(int16_t, int16_t, int64_t, |, bit_ior) +DEF_BIT_CVT_0(int16_t, uint16_t, uint32_t, |, bit_ior) +DEF_BIT_CVT_0(int16_t, uint16_t, uint64_t, |, bit_ior) +DEF_BIT_CVT_0(int16_t, uint16_t, int32_t, |, bit_ior) +DEF_BIT_CVT_0(int16_t, uint16_t, int64_t, |, bit_ior) + +DEF_BIT_CVT_0(int32_t, int32_t, uint64_t, |, bit_ior) +DEF_BIT_CVT_0(int32_t, int32_t, int64_t, |, bit_ior) +DEF_BIT_CVT_0(int32_t, uint32_t, uint64_t, |, bit_ior) +DEF_BIT_CVT_0(int32_t, uint32_t, int64_t, |, bit_ior) + +/* { dg-final { scan-tree-dump-not "_\[0-9]\+ = \\(u?int\[0-9]\+_t\\) _\[0-9]\+;\\s+return _\[0-9]\+;" "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/bit_op_cvt.3.c b/gcc/testsuite/gcc.dg/tree-ssa/bit_op_cvt.3.c new file mode 100644 index 0000000..8439345 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/bit_op_cvt.3.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +#include "bit_op_cvt.h" + +DEF_BIT_CVT_0(uint8_t, int8_t, uint16_t, &, bit_and) +DEF_BIT_CVT_0(uint8_t, int8_t, uint32_t, &, bit_and) +DEF_BIT_CVT_0(uint8_t, int8_t, uint64_t, &, bit_and) +DEF_BIT_CVT_0(uint8_t, uint8_t, uint16_t, &, bit_and) +DEF_BIT_CVT_0(uint8_t, uint8_t, uint32_t, &, bit_and) +DEF_BIT_CVT_0(uint8_t, uint8_t, uint64_t, &, bit_and) +DEF_BIT_CVT_0(uint8_t, uint8_t, int16_t, &, bit_and) +DEF_BIT_CVT_0(uint8_t, uint8_t, int32_t, &, bit_and) +DEF_BIT_CVT_0(uint8_t, uint8_t, int64_t, &, bit_and) +DEF_BIT_CVT_0(uint8_t, int8_t, int16_t, &, bit_and) +DEF_BIT_CVT_0(uint8_t, int8_t, int32_t, &, bit_and) +DEF_BIT_CVT_0(uint8_t, int8_t, int64_t, &, bit_and) + +DEF_BIT_CVT_0(uint16_t, int16_t, uint32_t, &, bit_and) +DEF_BIT_CVT_0(uint16_t, int16_t, uint64_t, &, bit_and) +DEF_BIT_CVT_0(uint16_t, int16_t, int32_t, &, bit_and) +DEF_BIT_CVT_0(uint16_t, int16_t, int64_t, &, bit_and) +DEF_BIT_CVT_0(uint16_t, uint16_t, uint32_t, &, bit_and) +DEF_BIT_CVT_0(uint16_t, uint16_t, uint64_t, &, bit_and) +DEF_BIT_CVT_0(uint16_t, uint16_t, int32_t, &, bit_and) +DEF_BIT_CVT_0(uint16_t, uint16_t, int64_t, &, bit_and) + +DEF_BIT_CVT_0(uint32_t, int32_t, uint64_t, &, bit_and) +DEF_BIT_CVT_0(uint32_t, int32_t, int64_t, &, bit_and) +DEF_BIT_CVT_0(uint32_t, uint32_t, uint64_t, &, bit_and) +DEF_BIT_CVT_0(uint32_t, uint32_t, int64_t, &, bit_and) + +/* { dg-final { scan-tree-dump-not "_\[0-9]\+ = \\(u?int\[0-9]\+_t\\) _\[0-9]\+;\\s+return _\[0-9]\+;" "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/bit_op_cvt.4.c b/gcc/testsuite/gcc.dg/tree-ssa/bit_op_cvt.4.c new file mode 100644 index 0000000..3f3356b --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/bit_op_cvt.4.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +#include "bit_op_cvt.h" + +DEF_BIT_CVT_0(int8_t, int8_t, uint16_t, &, bit_and) +DEF_BIT_CVT_0(int8_t, int8_t, uint32_t, &, bit_and) +DEF_BIT_CVT_0(int8_t, int8_t, uint64_t, &, bit_and) +DEF_BIT_CVT_0(int8_t, uint8_t, uint16_t, &, bit_and) +DEF_BIT_CVT_0(int8_t, uint8_t, uint32_t, &, bit_and) +DEF_BIT_CVT_0(int8_t, uint8_t, uint64_t, &, bit_and) +DEF_BIT_CVT_0(int8_t, uint8_t, int16_t, &, bit_and) +DEF_BIT_CVT_0(int8_t, uint8_t, int32_t, &, bit_and) +DEF_BIT_CVT_0(int8_t, uint8_t, int64_t, &, bit_and) +DEF_BIT_CVT_0(int8_t, int8_t, int16_t, &, bit_and) +DEF_BIT_CVT_0(int8_t, int8_t, int32_t, &, bit_and) +DEF_BIT_CVT_0(int8_t, int8_t, int64_t, &, bit_and) + +DEF_BIT_CVT_0(int16_t, int16_t, uint32_t, &, bit_and) +DEF_BIT_CVT_0(int16_t, int16_t, uint64_t, &, bit_and) +DEF_BIT_CVT_0(int16_t, int16_t, int32_t, &, bit_and) +DEF_BIT_CVT_0(int16_t, int16_t, int64_t, &, bit_and) +DEF_BIT_CVT_0(int16_t, uint16_t, uint32_t, &, bit_and) +DEF_BIT_CVT_0(int16_t, uint16_t, uint64_t, &, bit_and) +DEF_BIT_CVT_0(int16_t, uint16_t, int32_t, &, bit_and) +DEF_BIT_CVT_0(int16_t, uint16_t, int64_t, &, bit_and) + +DEF_BIT_CVT_0(int32_t, int32_t, uint64_t, &, bit_and) +DEF_BIT_CVT_0(int32_t, int32_t, int64_t, &, bit_and) +DEF_BIT_CVT_0(int32_t, uint32_t, uint64_t, &, bit_and) +DEF_BIT_CVT_0(int32_t, uint32_t, int64_t, &, bit_and) + +/* { dg-final { scan-tree-dump-not "_\[0-9]\+ = \\(u?int\[0-9]\+_t\\) _\[0-9]\+;\\s+return _\[0-9]\+;" "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/bit_op_cvt.5.c b/gcc/testsuite/gcc.dg/tree-ssa/bit_op_cvt.5.c new file mode 100644 index 0000000..e746d6e --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/bit_op_cvt.5.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +#include "bit_op_cvt.h" + +DEF_BIT_CVT_0(uint8_t, int8_t, uint16_t, ^, bit_xor) +DEF_BIT_CVT_0(uint8_t, int8_t, uint32_t, ^, bit_xor) +DEF_BIT_CVT_0(uint8_t, int8_t, uint64_t, ^, bit_xor) +DEF_BIT_CVT_0(uint8_t, uint8_t, uint16_t, ^, bit_xor) +DEF_BIT_CVT_0(uint8_t, uint8_t, uint32_t, ^, bit_xor) +DEF_BIT_CVT_0(uint8_t, uint8_t, uint64_t, ^, bit_xor) +DEF_BIT_CVT_0(uint8_t, uint8_t, int16_t, ^, bit_xor) +DEF_BIT_CVT_0(uint8_t, uint8_t, int32_t, ^, bit_xor) +DEF_BIT_CVT_0(uint8_t, uint8_t, int64_t, ^, bit_xor) +DEF_BIT_CVT_0(uint8_t, int8_t, int16_t, ^, bit_xor) +DEF_BIT_CVT_0(uint8_t, int8_t, int32_t, ^, bit_xor) +DEF_BIT_CVT_0(uint8_t, int8_t, int64_t, ^, bit_xor) + +DEF_BIT_CVT_0(uint16_t, int16_t, uint32_t, ^, bit_xor) +DEF_BIT_CVT_0(uint16_t, int16_t, uint64_t, ^, bit_xor) +DEF_BIT_CVT_0(uint16_t, int16_t, int32_t, ^, bit_xor) +DEF_BIT_CVT_0(uint16_t, int16_t, int64_t, ^, bit_xor) +DEF_BIT_CVT_0(uint16_t, uint16_t, uint32_t, ^, bit_xor) +DEF_BIT_CVT_0(uint16_t, uint16_t, uint64_t, ^, bit_xor) +DEF_BIT_CVT_0(uint16_t, uint16_t, int32_t, ^, bit_xor) +DEF_BIT_CVT_0(uint16_t, uint16_t, int64_t, ^, bit_xor) + +DEF_BIT_CVT_0(uint32_t, int32_t, uint64_t, ^, bit_xor) +DEF_BIT_CVT_0(uint32_t, int32_t, int64_t, ^, bit_xor) +DEF_BIT_CVT_0(uint32_t, uint32_t, uint64_t, ^, bit_xor) +DEF_BIT_CVT_0(uint32_t, uint32_t, int64_t, ^, bit_xor) + +/* { dg-final { scan-tree-dump-not "_\[0-9]\+ = \\(u?int\[0-9]\+_t\\) _\[0-9]\+;\\s+return _\[0-9]\+;" "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/bit_op_cvt.6.c b/gcc/testsuite/gcc.dg/tree-ssa/bit_op_cvt.6.c new file mode 100644 index 0000000..a12dc88 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/bit_op_cvt.6.c @@ -0,0 +1,33 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +#include "bit_op_cvt.h" + +DEF_BIT_CVT_0(int8_t, int8_t, uint16_t, ^, bit_xor) +DEF_BIT_CVT_0(int8_t, int8_t, uint32_t, ^, bit_xor) +DEF_BIT_CVT_0(int8_t, int8_t, uint64_t, ^, bit_xor) +DEF_BIT_CVT_0(int8_t, uint8_t, uint16_t, ^, bit_xor) +DEF_BIT_CVT_0(int8_t, uint8_t, uint32_t, ^, bit_xor) +DEF_BIT_CVT_0(int8_t, uint8_t, uint64_t, ^, bit_xor) +DEF_BIT_CVT_0(int8_t, uint8_t, int16_t, ^, bit_xor) +DEF_BIT_CVT_0(int8_t, uint8_t, int32_t, ^, bit_xor) +DEF_BIT_CVT_0(int8_t, uint8_t, int64_t, ^, bit_xor) +DEF_BIT_CVT_0(int8_t, int8_t, int16_t, ^, bit_xor) +DEF_BIT_CVT_0(int8_t, int8_t, int32_t, ^, bit_xor) +DEF_BIT_CVT_0(int8_t, int8_t, int64_t, ^, bit_xor) + +DEF_BIT_CVT_0(int16_t, int16_t, uint32_t, ^, bit_xor) +DEF_BIT_CVT_0(int16_t, int16_t, uint64_t, ^, bit_xor) +DEF_BIT_CVT_0(int16_t, int16_t, int32_t, ^, bit_xor) +DEF_BIT_CVT_0(int16_t, int16_t, int64_t, ^, bit_xor) +DEF_BIT_CVT_0(int16_t, uint16_t, uint32_t, ^, bit_xor) +DEF_BIT_CVT_0(int16_t, uint16_t, uint64_t, ^, bit_xor) +DEF_BIT_CVT_0(int16_t, uint16_t, int32_t, ^, bit_xor) +DEF_BIT_CVT_0(int16_t, uint16_t, int64_t, ^, bit_xor) + +DEF_BIT_CVT_0(int32_t, int32_t, uint64_t, ^, bit_xor) +DEF_BIT_CVT_0(int32_t, int32_t, int64_t, ^, bit_xor) +DEF_BIT_CVT_0(int32_t, uint32_t, uint64_t, ^, bit_xor) +DEF_BIT_CVT_0(int32_t, uint32_t, int64_t, ^, bit_xor) + +/* { dg-final { scan-tree-dump-not "_\[0-9]\+ = \\(u?int\[0-9]\+_t\\) _\[0-9]\+;\\s+return _\[0-9]\+;" "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/bit_op_cvt.h b/gcc/testsuite/gcc.dg/tree-ssa/bit_op_cvt.h new file mode 100644 index 0000000..87d67e6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/bit_op_cvt.h @@ -0,0 +1,13 @@ +#ifndef HAVE_DEFINED_BIT_OP_CVT +#define HAVE_DEFINED_BIT_OP_CVT + +#include <stdint.h> + +#define DEF_BIT_CVT_0(T1, T2, T3, OP, NAME) \ +T1 test_bit_##NAME##_##T1##_##T2##_##T3##_0(T2 a, \ + T3 b) \ +{ \ + return (T1)(a OP (T3)b); \ +} + +#endif diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ctz-ch.c b/gcc/testsuite/gcc.dg/tree-ssa/ctz-ch.c new file mode 100644 index 0000000..5d72597 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ctz-ch.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +typedef unsigned long BITMAP_WORD; + +bool +bmp_iter_set (BITMAP_WORD bits, unsigned *bit_no) +{ + /* If our current word is nonzero, it contains the bit we want. */ + if (bits) + { + while (!(bits & 1)) + { + bits >>= 1; + *bit_no += 1; + } + return true; + } + + return false; +} + +/* { dg-final { scan-tree-dump-times "__builtin_ctz|\\.CTZ" 1 "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ctz-char.c b/gcc/testsuite/gcc.dg/tree-ssa/ctz-char.c index 3cd166a..fa8b7f3 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ctz-char.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ctz-char.c @@ -1,6 +1,6 @@ /* { dg-do run } */ /* { dg-require-effective-target ctz } */ -/* { dg-options "-O2 -fno-tree-ch -fdump-tree-optimized" } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ #define PREC (__CHAR_BIT__) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ctz-complement-char.c b/gcc/testsuite/gcc.dg/tree-ssa/ctz-complement-char.c index b9afe88..5ebc321 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ctz-complement-char.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ctz-complement-char.c @@ -1,6 +1,6 @@ /* { dg-do run } */ /* { dg-require-effective-target ctz } */ -/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-options "-O2 -fno-tree-ch -fdump-tree-optimized" } */ #define PREC (__CHAR_BIT__) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ctz-complement-int.c b/gcc/testsuite/gcc.dg/tree-ssa/ctz-complement-int.c index d2702a6..0ce4b6b 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ctz-complement-int.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ctz-complement-int.c @@ -1,6 +1,6 @@ /* { dg-do run } */ /* { dg-require-effective-target ctz } */ -/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-options "-O2 -fno-tree-ch -fdump-tree-optimized" } */ #define PREC (__CHAR_BIT__ * __SIZEOF_INT__) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ctz-complement-long-long.c b/gcc/testsuite/gcc.dg/tree-ssa/ctz-complement-long-long.c index 1ea0d5d..f98bec0 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ctz-complement-long-long.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ctz-complement-long-long.c @@ -1,6 +1,6 @@ /* { dg-do run } */ /* { dg-require-effective-target ctzll } */ -/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-options "-O2 -fno-tree-ch -fdump-tree-optimized" } */ #define PREC (__CHAR_BIT__ * __SIZEOF_LONG_LONG__) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ctz-complement-long.c b/gcc/testsuite/gcc.dg/tree-ssa/ctz-complement-long.c index 80fb02d..8edb372 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ctz-complement-long.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ctz-complement-long.c @@ -1,6 +1,6 @@ /* { dg-do run } */ /* { dg-require-effective-target ctzl } */ -/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-options "-O2 -fno-tree-ch -fdump-tree-optimized" } */ #define PREC (__CHAR_BIT__ * __SIZEOF_LONG__) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ctz-int.c b/gcc/testsuite/gcc.dg/tree-ssa/ctz-int.c index 7f63493..2bf3ae6 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ctz-int.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ctz-int.c @@ -1,6 +1,6 @@ /* { dg-do run } */ /* { dg-require-effective-target ctz } */ -/* { dg-options "-O2 -fno-tree-ch -fdump-tree-optimized" } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ #define PREC (__CHAR_BIT__ * __SIZEOF_INT__) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ctz-long-long.c b/gcc/testsuite/gcc.dg/tree-ssa/ctz-long-long.c index 924f61b..2e15948 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ctz-long-long.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ctz-long-long.c @@ -1,6 +1,6 @@ /* { dg-do run } */ /* { dg-require-effective-target ctzll } */ -/* { dg-options "-O2 -fno-tree-ch -fdump-tree-optimized" } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ #define PREC (__CHAR_BIT__ * __SIZEOF_LONG_LONG__) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ctz-long.c b/gcc/testsuite/gcc.dg/tree-ssa/ctz-long.c index 178945d..2e3be65 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ctz-long.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ctz-long.c @@ -1,6 +1,6 @@ /* { dg-do run } */ /* { dg-require-effective-target ctzl } */ -/* { dg-options "-O2 -fno-tree-ch -fdump-tree-optimized" } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ #define PREC (__CHAR_BIT__ * __SIZEOF_LONG__) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/forwprop-43.c b/gcc/testsuite/gcc.dg/tree-ssa/forwprop-43.c new file mode 100644 index 0000000..bfda376 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/forwprop-43.c @@ -0,0 +1,171 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-forwprop1" } */ +/* { dg-require-effective-target stdint_types } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fgimple" } */ + +#include <stdint.h> + +typedef int32_t int32x4_t __attribute__((vector_size(16))); +typedef int32_t int32x2_t __attribute__((vector_size(8))); +typedef int32_t int32x1_t __attribute__((vector_size(4))); + +int32x4_t __GIMPLE (ssa) +foo (int32x4_t x) +{ + int32x2_t _1; + int32x2_t _2; + int32x4_t _6; + +__BB(2): + _1 = __BIT_FIELD_REF <int32x2_t> (x, 64, 64); + _2 = __BIT_FIELD_REF <int32x2_t> (x, 64, 0); + _6 = _Literal (int32x4_t) { _1, _2 }; + return _6; +} + +int32x4_t __GIMPLE (ssa) +foo2 (int32x4_t x) +{ + int32x1_t _1; + int32x1_t _2; + int32x1_t _3; + int32x1_t _4; + int32x4_t _6; + +__BB(2): + _1 = __BIT_FIELD_REF <int32x1_t> (x, 32, 64); + _2 = __BIT_FIELD_REF <int32x1_t> (x, 32, 96); + _3 = __BIT_FIELD_REF <int32x1_t> (x, 32, 0); + _4 = __BIT_FIELD_REF <int32x1_t> (x, 32, 32); + _6 = _Literal (int32x4_t) { _1, _2, _3, _4 }; + return _6; +} + +int32x4_t __GIMPLE (ssa) +foo3 (int32x4_t x, int32x4_t y) +{ + int32x2_t _1; + int32x2_t _2; + int32x4_t _6; + +__BB(2): + _1 = __BIT_FIELD_REF <int32x2_t> (x, 64, 64); + _2 = __BIT_FIELD_REF <int32x2_t> (y, 64, 0); + _6 = _Literal (int32x4_t) { _1, _2 }; + return _6; +} + +int32x4_t __GIMPLE (ssa) +foo4 (int32x4_t x, int32x4_t y) +{ + int32x1_t _1; + int32x1_t _2; + int32x1_t _3; + int32x1_t _4; + int32x4_t _6; + +__BB(2): + _1 = __BIT_FIELD_REF <int32x1_t> (x, 32, 64); + _2 = __BIT_FIELD_REF <int32x1_t> (y, 32, 96); + _3 = __BIT_FIELD_REF <int32x1_t> (x, 32, 0); + _4 = __BIT_FIELD_REF <int32x1_t> (y, 32, 32); + _6 = _Literal (int32x4_t) { _1, _2, _3, _4 }; + return _6; +} + +int32x4_t __GIMPLE (ssa) +foo5 (int32x4_t x) +{ + int32x2_t _1; + int32x2_t _2; + int32x4_t _6; + +__BB(2): + _1 = __BIT_FIELD_REF <int32x2_t> (x, 64, 64); + _2 = _Literal (int32x2_t) { 1, 2 }; + _6 = _Literal (int32x4_t) { _1, _2 }; + return _6; +} + +int32x4_t __GIMPLE (ssa) +foo6 (int32x4_t x, int32_t y) +{ + int32x2_t _1; + int32x2_t _2; + int32x4_t _6; + +__BB(2): + _1 = __BIT_FIELD_REF <int32x2_t> (x, 64, 64); + _2 = _Literal (int32x2_t) { y, y }; + _6 = _Literal (int32x4_t) { _1, _2 }; + return _6; +} + +int32x4_t __GIMPLE (ssa) +foo7 (int32x4_t x) +{ + int32x2_t _1; + int32x2_t _2; + int32x4_t _6; + +__BB(2): + _1 = __BIT_FIELD_REF <int32x2_t> (x, 64, 64); + _2 = _Literal (int32x2_t) { 1, 2 }; + _6 = _Literal (int32x4_t) { _2, _1 }; + return _6; +} + +int32x4_t __GIMPLE (ssa) +foo8 (int32x4_t x, int32_t y) +{ + int32x2_t _1; + int32x2_t _2; + int32x4_t _6; + +__BB(2): + _1 = __BIT_FIELD_REF <int32x2_t> (x, 64, 64); + _2 = _Literal (int32x2_t) { y, y }; + _6 = _Literal (int32x4_t) { _2, _1 }; + return _6; +} + +int32x4_t __GIMPLE (ssa) +foo9 (int32x4_t x) +{ + int32x1_t _1; + int32x1_t _2; + int32x1_t _3; + int32x1_t _4; + int32x4_t _6; + +__BB(2): + _1 = __BIT_FIELD_REF <int32x1_t> (x, 32, 96); + _2 = __BIT_FIELD_REF <int32x1_t> (x, 32, 64); + _3 = _Literal (int32x1_t) { 1 }; + _4 = _Literal (int32x1_t) { 1 }; + _6 = _Literal (int32x4_t) { _3, _4, _1, _2 }; + return _6; +} + +int32x4_t __GIMPLE (ssa) +foo10 (int32x4_t x, int32_t y) +{ + int32x1_t _1; + int32x1_t _2; + int32x1_t _3; + int32x1_t _4; + int32x4_t _6; + +__BB(2): + _1 = __BIT_FIELD_REF <int32x1_t> (x, 32, 96); + _2 = __BIT_FIELD_REF <int32x1_t> (x, 32, 64); + _3 = _Literal (int32x1_t) { y }; + _4 = _Literal (int32x1_t) { y }; + _6 = _Literal (int32x4_t) { _3, _4, _1, _2 }; + + return _6; +} + + +/* { dg-final { scan-tree-dump-times "VEC_PERM_EXPR" 10 "forwprop1" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phiprop-3.c b/gcc/testsuite/gcc.dg/tree-ssa/phiprop-3.c new file mode 100644 index 0000000..59e9561 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/phiprop-3.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fdump-tree-phiprop1-details" } */ + +/* PR tree-optimization/60183 */ + +unsigned char c; +extern unsigned char d; +int j = 2; + +unsigned long +foo (void) +{ + unsigned char *y = &c; + int i; + unsigned w = 0; + for (i = 0; i < j; i++) + { + w = *y; + y = &d; + } + return w; +} +/* the load from c/d does not trap so we should able to remove the phi. */ +/* { dg-final { scan-tree-dump "Removing dead stmt:" "phiprop1"} } */ +/* { dg-final { scan-tree-dump "Inserting PHI for result of load" "phiprop1"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phiprop-4.c b/gcc/testsuite/gcc.dg/tree-ssa/phiprop-4.c new file mode 100644 index 0000000..ceb03ed --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/phiprop-4.c @@ -0,0 +1,26 @@ +/* { dg-do compile { target { weak_undefined } } } */ +/* { dg-options "-O1 -fdump-tree-phiprop1-details" } */ +/* { dg-add-options weak_undefined } */ + +/* PR tree-optimization/60183 */ + +unsigned char c; +extern unsigned char d __attribute__((weak)); +int j = 2; + +unsigned long +foo (void) +{ + unsigned char *y = &c; + int i; + unsigned w = 0; + for (i = 0; i < j; i++) + { + w = *y; + y = &d; + } + return w; +} +/* the load from d can trap so this should not cause a phiprop. */ +/* { dg-final { scan-tree-dump-not "Removing dead stmt:" "phiprop1"} } */ +/* { dg-final { scan-tree-dump-not "Inserting PHI for result of load" "phiprop1"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phiprop-5.c b/gcc/testsuite/gcc.dg/tree-ssa/phiprop-5.c new file mode 100644 index 0000000..b76b17c --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/phiprop-5.c @@ -0,0 +1,26 @@ +/* { dg-do compile { target { weak_undefined } } } */ +/* { dg-options "-O1 -fdump-tree-phiprop1-details" } */ +/* { dg-add-options weak_undefined } */ + +/* PR tree-optimization/60183 */ + +unsigned char c; +extern unsigned char d __attribute__((weak)); +int j = 2; + +unsigned long +foo (void) +{ + unsigned char *y = &c; + int i; + unsigned w = 0; + for (i = 0; i < *y; i++) + { + w = *y; + y = &d; + } + return w; +} +/* the load from d can trap but the load always happen so this should be done. */ +/* { dg-final { scan-tree-dump "Removing dead stmt:" "phiprop1"} } */ +/* { dg-final { scan-tree-dump "Inserting PHI for result of load" "phiprop1"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phiprop-6.c b/gcc/testsuite/gcc.dg/tree-ssa/phiprop-6.c new file mode 100644 index 0000000..8561cd1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/phiprop-6.c @@ -0,0 +1,21 @@ +/* { dg-do compile { target { weak_undefined } } } */ +/* { dg-options "-O2 -fdump-tree-phiprop-details" } */ +/* { dg-add-options weak_undefined } */ + +/* PR tree-optimization/116835 */ + +extern int a __attribute__((weak)); +int b; + +int +bar (int c) +{ + int *p = &a; + for (int j = 0; j < c; ++j) + p = &b; + return *p; +} +/* The weak load is conditional with the loop so we cannot make it unconditional. */ +/* { dg-final { scan-tree-dump-not "Removing dead stmt:" "phiprop1"} } */ +/* { dg-final { scan-tree-dump-not "Inserting PHI for result of load" "phiprop1"} } */ + diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phiprop-7.c b/gcc/testsuite/gcc.dg/tree-ssa/phiprop-7.c new file mode 100644 index 0000000..ebce03e --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/phiprop-7.c @@ -0,0 +1,21 @@ +/* { dg-do compile { target { weak_undefined } } } */ +/* { dg-options "-O2 -fdump-tree-phiprop-details" } */ +/* { dg-add-options weak_undefined } */ + +/* PR tree-optimization/116835 */ + +extern int a __attribute__((weak)); +int b; + +int +bar (int c) +{ + int *p = &a; + for (int j = 0; j < *p; ++j) + p = &b; + return *p; +} +/* The weak load is unconditional due to the conditional so we can remove it unconditionally. */ +/* { dg-final { scan-tree-dump "Removing dead stmt:" "phiprop1"} } */ +/* { dg-final { scan-tree-dump "Inserting PHI for result of load" "phiprop1"} } */ + diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr119683.c b/gcc/testsuite/gcc.dg/tree-ssa/pr119683.c new file mode 100644 index 0000000..631ab43 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr119683.c @@ -0,0 +1,19 @@ +/* PR tree-optimization/119683 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-final { scan-tree-dump-times " = c_\[0-9]*\\\(D\\\) \\\+ \(?:\[0-9-]\)+;" 3 "optimized" } } */ + +unsigned +foo (signed char c) +{ + if (c >= '0' && c <= '9') + return c - '0'; + + if (c >= 'a' && c <= 'z') + return c - 'a' + 10; + + if (c >= 'A' && c <= 'Z') + return c - 'A' + 10; + + return -1; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr122478.c b/gcc/testsuite/gcc.dg/tree-ssa/pr122478.c new file mode 100644 index 0000000..a39c91b --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr122478.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-additional-options "-fgimple" } */ + +unsigned char __GIMPLE (ssa) +foo (unsigned short mask__701) +{ + _Bool _19; + unsigned char _180; + +__BB(2): + _19 = __BIT_FIELD_REF <_Bool> (mask__701, 1, 12); + _180 = __VIEW_CONVERT<unsigned char>(_19); + return _180; +} + +/* { dg-final { scan-tree-dump-times "VIEW_CONVERT_EXPR" 1 "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr122588-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr122588-1.c new file mode 100644 index 0000000..2c214c9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr122588-1.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -fgimple" } */ +/* PR tree-optimization/122588 */ + +/* The removal of unreachable blocks should not + change blocks which have already become true/false. + The function below was is an example of that. And + forwprop does not go into non-executable blocks + so the statement `t = _1;` was still holding the + old reference. */ + +int t; + +__GIMPLE(ssa,startwith("forwprop4")) void g(void) +{ + int _1; + __BB(2): + _1 = 1; + if (_1 != 0) + goto __BB3; + else + goto __BB4; + + __BB(3): + __builtin_unreachable (); + + __BB(4): + t = _1; + return; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr122629-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr122629-1.c new file mode 100644 index 0000000..a80d4a1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr122629-1.c @@ -0,0 +1,36 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-ifcvt-details" } */ +/* PR tree-optimization/122629 */ + +typedef int ix4 __attribute__((vector_size(4*sizeof(int)))); + +int f(ix4 *a, int l, int *b, ix4 *c) +{ + for (int i =0 ;i < l; i++) + { + int t; + ix4 tt = a[i]; + ix4 tt1 = c[i]; + if(*b) t = tt1[0]; else t = tt[0]; + *b = t; + } +} + +int g(ix4 *a, int l, int *b, ix4 *c) +{ + for (int i =0 ;i < l; i++) + { + ix4 tt = a[i]; + ix4 tt1 = c[i]; + if(*b) { + tt = tt1; + tt[0] = 1; + } else { + tt[0] = 1; + } + a[i] = tt; + } +} + +/* Make sure BIT_INSERT_EXPR/BIT_FIELD_REF is still factored out for the case if operand 0 is different. */ +/* { dg-final { scan-tree-dump-times "changed to factor operation out from" 2 "ifcvt" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr46555.c b/gcc/testsuite/gcc.dg/tree-ssa/pr46555.c new file mode 100644 index 0000000..d4de7c2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr46555.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized-details -fdump-rtl-pro_and_epilogue" } */ +/* PR tree-optimization/46555 */ +/* Here should not remove the forwarder block (or rather recreate it and not + remove it again). This improves expansion to RTL as there is one less copy + (or constant formation) in some cases. In this case we also get the ability + to shrink wrap the function. */ + +int h(void); +int f(int a, int b, int c) +{ + if (a) + return 2; + h(); + if (b) + return 2; + h(); + if (c) + return 2; + h(); + return 4; +} + +/* { dg-final { scan-tree-dump-times "New forwarder block for edge" 1 "optimized" } } */ +/* Make sure we only have a PHI with 2 arguments here, 2 and 4. */ +/* { dg-final { scan-tree-dump "PHI <2..., 4...>|PHI <4..., 2...>" "optimized" } } */ +/* Make sure we can shrink wrap the function now too. */ +/* { dg-final { scan-rtl-dump "Performing shrink-wrapping" "pro_and_epilogue" { target { { { i?86-*-* x86_64-*-* } && { ! ia32 } } || { powerpc*-*-* aarch64*-*-* riscv*-*-* arm*-*-* } } } } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr92834.c b/gcc/testsuite/gcc.dg/tree-ssa/pr92834.c index 889048d..70acf74 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr92834.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr92834.c @@ -1,8 +1,8 @@ /* PR tree-optimization/92834 */ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-optimized" } */ -/* { dg-final { scan-tree-dump-times "MIN_EXPR <" 8 "optimized" } } */ -/* { dg-final { scan-tree-dump-times "MAX_EXPR <" 8 "optimized" } } */ +/* { dg-options "-O2 -fdump-tree-phiopt1" } */ +/* { dg-final { scan-tree-dump-times "MIN_EXPR <" 16 "phiopt1" } } */ +/* { dg-final { scan-tree-dump-times "MAX_EXPR <" 16 "phiopt1" } } */ static inline unsigned umax1 (unsigned a, unsigned b) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/scev-16.c b/gcc/testsuite/gcc.dg/tree-ssa/scev-16.c new file mode 100644 index 0000000..0cc7f70 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/scev-16.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-sccp" } */ + +extern char a[]; +int foo () +{ + int cnt = 0; + char *aend = a + 32; + char *a0 = a; + do + { + a0 = a0 + 16; + cnt++; + } + while (aend - a0 > 12); + return cnt; +} + +/* { dg-final { scan-tree-dump "return 2" "sccp" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-7.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-7.c index 1c2cfa4..81bb7fc 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-7.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-7.c @@ -11,8 +11,8 @@ to change decisions in switch expansion which in turn can expose new jump threading opportunities. Skip the later tests on aarch64. */ /* { dg-final { scan-tree-dump-not "Jumps threaded" "dom3" { target { ! aarch64*-*-* } } } } */ -/* { dg-final { scan-tree-dump "Jumps threaded: 8" "thread2" { target { ! aarch64*-*-* } } } } */ -/* { dg-final { scan-tree-dump "Jumps threaded: 8" "thread2" { target { aarch64*-*-* } } } } */ +/* { dg-final { scan-tree-dump "Jumps threaded: 12" "thread2" { target { ! aarch64*-*-* } } } } */ +/* { dg-final { scan-tree-dump "Jumps threaded: 12" "thread2" { target { aarch64*-*-* } } } } */ enum STATE { S0=0, diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp-from-cst-agg-1.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp-from-cst-agg-1.c new file mode 100644 index 0000000..6612a88 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp-from-cst-agg-1.c @@ -0,0 +1,32 @@ +/* { dg-do link } */ +/* { dg-options "-O2" } */ + +int ga = 1; +int gb = 2; +int gc = 3; +volatile int gi; + +static const int *vars[3] = {&ga, &gb, &gc}; + +void link_error (void); + +[[gnu::noinline]] void foo (int index) +{ + const int *p = vars[index]; + if (!p) + link_error (); + else + gi = *p; +} + +[[gnu::noipa]] int +get_index (void) +{ + return 1; +} + +int main (int argc, char **argv) +{ + foo (get_index ()); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp-from-cst-agg-2.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp-from-cst-agg-2.c new file mode 100644 index 0000000..0f7677d --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp-from-cst-agg-2.c @@ -0,0 +1,57 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +enum comp_cat_tag +{ + cc_partial_ordering, + cc_weak_ordering, + cc_strong_ordering, + cc_last +}; + +struct comp_cat_info_t +{ + const char *name; + const char *members[4]; +}; + +static const struct comp_cat_info_t comp_cat_info[cc_last] += { + { "partial_ordering", { "equivalent", "greater", "less", "unordered" } }, + { "weak_ordering", { "equivalent", "greater", "less" } }, + { "strong_ordering", { "equal", "greater", "less" } } +}; + +volatile const char *gp; + +[[gnu::noipa]] static void +check (const char *p) +{ + if (!p) + __builtin_abort (); + gp = p; +} + +[[gnu::noinline]] int foo (enum comp_cat_tag tag) +{ + for (int i = 0; i < 4; ++i) + { + const char *p = comp_cat_info[tag].members[i]; + if (!p) + continue;; + check (p); + } + return 0; +} + +[[gnu::noipa]] enum comp_cat_tag +get_index (void) +{ + return cc_strong_ordering; +} + +int main (int argc, char **argv) +{ + foo (get_index ()); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp-from-cst-agg-3.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp-from-cst-agg-3.c new file mode 100644 index 0000000..d7a5e61 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp-from-cst-agg-3.c @@ -0,0 +1,30 @@ +/* { dg-do link } */ +/* { dg-options "-O2" } */ + +volatile int gi; + +static const int values[3] = {5, 7, 11}; + +void link_error (void); + +[[gnu::noinline]] void foo (int index) +{ + const int v = values[index]; + if (v <= 2 + || v > 11) + link_error (); + else + gi = v; +} + +[[gnu::noipa]] int +get_index (void) +{ + return 1; +} + +int main (int argc, char **argv) +{ + foo (get_index ()); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp-from-cst-agg-4.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp-from-cst-agg-4.c new file mode 100644 index 0000000..333a24b --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp-from-cst-agg-4.c @@ -0,0 +1,30 @@ +/* { dg-do link } */ +/* { dg-options "-O2" } */ + +volatile int gi; + +static const int values[25] = {5, 7, 11}; + +void link_error (void); + +[[gnu::noinline]] void foo (int index) +{ + const int v = values[index]; + if (v <= -2 + || v > 11) + link_error (); + else + gi = v; +} + +[[gnu::noipa]] int +get_index (void) +{ + return 1; +} + +int main (int argc, char **argv) +{ + foo (get_index ()); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp-from-cst-agg-5.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp-from-cst-agg-5.c new file mode 100644 index 0000000..08e2117 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp-from-cst-agg-5.c @@ -0,0 +1,36 @@ +/* { dg-do link } */ +/* { dg-options "-O2" } */ + +volatile int gi; + +static const struct { + int a; + int b; +} values[2][2] = { + { {1000, 1 }, {1001, 2} }, + { {1003, 1 }, {1004, 2} } +}; + +void link_error (void); + +[[gnu::noinline]] void foo (int i, int j) +{ + const int v = values[i][j].b; + if (v <= 0 + || v > 2) + link_error (); + else + gi = v; +} + +[[gnu::noipa]] int +get_index (void) +{ + return 1; +} + +int main (int argc, char **argv) +{ + foo (get_index (), get_index ()); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp-from-cst-agg-6.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp-from-cst-agg-6.c new file mode 100644 index 0000000..6f93f09 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp-from-cst-agg-6.c @@ -0,0 +1,42 @@ +/* { dg-do run } */ +/* { dg-options "-O2" } */ + +volatile int gi; + +static const struct { + int a; + int b; +} values[2][2] = { + { {0, 1 }, {0, 2} }, + { {0, 1 }, {0, 2} } +}; + +[[gnu::noipa]] static void +check (int v) +{ + if (!v) + __builtin_abort (); + gi = v; +} + + +[[gnu::noinline]] void foo (int i, int j) +{ + const int v = values[i][j].a; + if (v <= 0 + || v > 2) + return; + check (v); +} + +[[gnu::noipa]] int +get_index (void) +{ + return 1; +} + +int main (int argc, char **argv) +{ + foo (get_index (), get_index ()); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp-from-cst-agg-7.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp-from-cst-agg-7.c new file mode 100644 index 0000000..da01abb --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp-from-cst-agg-7.c @@ -0,0 +1,36 @@ +/* { dg-do link } */ +/* { dg-options "-O2" } */ + +volatile int gi; + +static const struct { + int a; + int b; +} values[2][2] = { + { {1000, 1 }, {1001, 2} }, + { {1003, 1 }, {1004, 2} } +}; + +void link_error (void); + +[[gnu::noinline]] void foo (int i) +{ + const int v = values[0][i].b; + if (v <= 0 + || v > 2) + link_error (); + else + gi = v; +} + +[[gnu::noipa]] int +get_index (void) +{ + return 1; +} + +int main (int argc, char **argv) +{ + foo (get_index ()); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/uninit-pred-7_a.c b/gcc/testsuite/gcc.dg/uninit-pred-7_a.c index c2ba2a4..7aaadf7 100644 --- a/gcc/testsuite/gcc.dg/uninit-pred-7_a.c +++ b/gcc/testsuite/gcc.dg/uninit-pred-7_a.c @@ -20,7 +20,7 @@ int foo (int n, int l, int m, int r) blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ if ( n ) - blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ + blah(v); /* { dg-bogus "uninitialized" "bogus warning" { xfail *-*-* } } */ if ( l ) blah(v); /* { dg-bogus "uninitialized" "bogus warning" } */ diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-41.c b/gcc/testsuite/gcc.dg/vect/bb-slp-41.c index 5a2bd4d..89e0bcd 100644 --- a/gcc/testsuite/gcc.dg/vect/bb-slp-41.c +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-41.c @@ -59,4 +59,4 @@ int main () return 0; } -/* { dg-final { scan-tree-dump-not "vectorizing stmts using SLP" "slp1" } } */ +/* { dg-final { scan-tree-dump-not "vectorizable constructor" "slp1" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/complex/complex-operations-run.c b/gcc/testsuite/gcc.dg/vect/complex/vect-complex-operations-run.c index 2f916ab..2f916ab 100644 --- a/gcc/testsuite/gcc.dg/vect/complex/complex-operations-run.c +++ b/gcc/testsuite/gcc.dg/vect/complex/vect-complex-operations-run.c diff --git a/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-pr122573.c b/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-pr122573.c new file mode 100644 index 0000000..ca3294d --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-pr122573.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-march=znver5" } */ + +struct S { + float m_col1[4]; + float m_col2[4]; + float m_col3[4]; + float m_col4[4]; +}; + +void apply(struct S *s, const float *in, float *out, long numPixels) +{ + for (long idx = 0; idx < numPixels; ++idx) + { + const float r = in[0]; + const float g = in[1]; + const float b = in[2]; + const float a = in[3]; + out[0] = r*s->m_col1[0] + g*s->m_col2[0] + b*s->m_col3[0] + a*s->m_col4[0]; + out[1] = r*s->m_col1[1] + g*s->m_col2[1] + b*s->m_col3[1] + a*s->m_col4[1]; + out[2] = r*s->m_col1[2] + g*s->m_col2[2] + b*s->m_col3[2] + a*s->m_col4[2]; + out[3] = r*s->m_col1[3] + g*s->m_col2[3] + b*s->m_col3[3] + a*s->m_col4[3]; + in += 4; + out += 4; + } +} + +/* Check that we do not use a masked epilog but a SSE one with VF 1 + (and possibly a AVX2 one as well). */ +/* { dg-final { scan-tree-dump "optimized: epilogue loop vectorized using 16 byte vectors and unroll factor 1" "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/pr122475.c b/gcc/testsuite/gcc.dg/vect/pr122475.c new file mode 100644 index 0000000..ed229c5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr122475.c @@ -0,0 +1,13 @@ +/* { dg-additional-options "-march=armv8-a+sve" { target aarch64*-*-* } } */ +/* Check that we don't ICE. */ +int a; +int b; +int main() { + for (char t = 0; t < 14; t += 2) + for (int u = 0; u < 242; u += 4) { + a = a < 0 ? a : 0; + b = b < 0 ? b : 0; + } +} + +/* { dg-final { scan-tree-dump-times "optimized: loop vectorized" 1 "vect" { target aarch64*-*-* } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/pr122680.c b/gcc/testsuite/gcc.dg/vect/pr122680.c new file mode 100644 index 0000000..3e25a3f --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr122680.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ +/* { dg-additional-options "-mavx2" { target avx2 } } */ + +void +foo (float *buf) +{ + for (unsigned long i = 0, j = 100; i < 100; i++, j--) + buf[i] = j; +} diff --git a/gcc/testsuite/gcc.dg/vect/pr122797.c b/gcc/testsuite/gcc.dg/vect/pr122797.c new file mode 100644 index 0000000..11819ef --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr122797.c @@ -0,0 +1,27 @@ +/* { dg-do run } */ +/* { dg-additional-options "-O3" } */ + +int src_stride = 0; +int dst_stride = 0; + +int main() { + char src[12] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; + char dst[16]; + char *s = src; + char *d = dst; + for (int i = 0; i < 2; i++) { + d[0] = s[0] + s[1] + s[2] + s[3] + s[4]; + d[1] = s[1] + s[2] + s[3] + s[4] + s[5]; + d[2] = s[2] + s[3] + s[4] + s[5] + s[6]; + d[3] = s[3] + s[4] + s[5] + s[6] + s[7]; + d[4] = s[4] + s[5] + s[6] + s[7] + s[8]; + d[5] = s[5] + s[6] + s[7] + s[8] + s[9]; + d[6] = s[6] + s[7] + s[8] + s[9] + s[10]; + d[7] = s[7] + s[8] + s[9] + s[10] + s[11]; + s += src_stride; + d += dst_stride; + } + + if (d[0] != 15) + __builtin_abort (); +} diff --git a/gcc/testsuite/gcc.dg/vect/pr122850.c b/gcc/testsuite/gcc.dg/vect/pr122850.c new file mode 100644 index 0000000..4f50aa9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr122850.c @@ -0,0 +1,13 @@ +/* { dg-do compile { target { x86_64-*-* i?86-*-* } } } */ +/* { dg-additional-options "-O3 -march=haswell -m32" } */ + +typedef int v2ll __attribute__ ((__vector_size__ (2 * sizeof (int)))); +typedef unsigned int v2ull __attribute__ ((__vector_size__ (2 * sizeof (int)))); +typedef __attribute__ ((__vector_size__ (2 * sizeof (short)))) short v2s; + +v2ll +f (v2ull e) +{ + v2s c = (v2s) e[0]; + return (v2ll) {(int) c, 0}; +} diff --git a/gcc/testsuite/gcc.dg/vect/pr122855.c b/gcc/testsuite/gcc.dg/vect/pr122855.c new file mode 100644 index 0000000..3084d20 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr122855.c @@ -0,0 +1,15 @@ +/* { dg-do compile { target { x86_64-*-* i?86-*-* } } } */ +/* { dg-additional-options "-O3 -march=haswell" } */ + +int zoom_x3_weights_0, zoom_x3_j, zoom_x3_pixel2; + +void zoom_x3(char *__restrict s, char *__restrict zoom_x3_tmp) { + int pixel0 = 0, pixel1 = 0; + for (; zoom_x3_j; zoom_x3_j--) { + pixel0 += *s++ * zoom_x3_weights_0; + pixel1 += *s++ * zoom_x3_weights_0; + zoom_x3_pixel2 += *s++ * zoom_x3_weights_0; + } + *zoom_x3_tmp++ = pixel0 < 0 ? 0 : pixel0 > 255 ? 255 : pixel0; + *zoom_x3_tmp = pixel1 < 0 ? 0 : pixel1 > 255 ? 255 : pixel1; +} diff --git a/gcc/testsuite/gcc.dg/vect/pr122969.c b/gcc/testsuite/gcc.dg/vect/pr122969.c new file mode 100644 index 0000000..47699fd --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr122969.c @@ -0,0 +1,16 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-w -O3 -fno-tree-dominator-opts -fno-code-hoisting -fno-tree-pre -fno-tree-dce" } */ + +/* { dg-final { scan-tree-dump "loop vectorized" "vect" } } */ + +int a, b; +int main() { + while (a) + for (a = 0; a != 1; a--) + if (b) + break; + return 0; +} + diff --git a/gcc/testsuite/gcc.dg/vect/pr123038.c b/gcc/testsuite/gcc.dg/vect/pr123038.c new file mode 100644 index 0000000..bca831f --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr123038.c @@ -0,0 +1,8 @@ +/* { dg-do compile } */ + +unsigned char f(int b) +{ + for (int a = 0; a < 10; a += 1) + b = __builtin_ffs(b); + return b; +} diff --git a/gcc/testsuite/gcc.dg/vect/slp-58.c b/gcc/testsuite/gcc.dg/vect/slp-58.c new file mode 100644 index 0000000..e03cfa3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/slp-58.c @@ -0,0 +1,28 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ + +struct S { + float m_col1[4]; + float m_col2[4]; + float m_col3[4]; + float m_col4[4]; +}; + +void apply(struct S *s, const float *in, float *out, long numPixels) +{ + for (long idx = 0; idx < numPixels; ++idx) + { + const float r = in[0]; + const float g = in[1]; + const float b = in[2]; + const float a = in[3]; + out[0] = r*s->m_col1[0] + g*s->m_col2[0] + b*s->m_col3[0] + a*s->m_col4[0]; + out[1] = r*s->m_col1[1] + g*s->m_col2[1] + b*s->m_col3[1] + a*s->m_col4[1]; + out[2] = r*s->m_col1[2] + g*s->m_col2[2] + b*s->m_col3[2] + a*s->m_col4[2]; + out[3] = r*s->m_col1[3] + g*s->m_col2[3] + b*s->m_col3[3] + a*s->m_col4[3]; + in += 4; + out += 4; + } +} + +/* { dg-final { scan-tree-dump "vectorization factor = 1" "vect" { target { ! vect_load_lanes } } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/slp-9.c b/gcc/testsuite/gcc.dg/vect/slp-9.c index 4fb6953..8869764 100644 --- a/gcc/testsuite/gcc.dg/vect/slp-9.c +++ b/gcc/testsuite/gcc.dg/vect/slp-9.c @@ -1,5 +1,4 @@ /* { dg-require-effective-target vect_int } */ -/* { dg-additional-options "-fno-early-inlining" } */ #include <stdarg.h> #include "tree-vect.h" @@ -11,7 +10,7 @@ short Y[N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))); int result[N]; /* short->int widening-mult */ -int +int __attribute__((noipa)) foo1(int len) { int i; diff --git a/gcc/testsuite/gcc.dg/vect/slp-reduc-13.c b/gcc/testsuite/gcc.dg/vect/slp-reduc-13.c new file mode 100644 index 0000000..00e91fc --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/slp-reduc-13.c @@ -0,0 +1,66 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-additional-options "-fgimple" } */ + +int q[2]; + +void __GIMPLE (ssa,guessed_local(16535624),startwith("loop")) +foo (int * r) +{ + int i; + int sum2; + int sum1; + int _1; + long unsigned int _2; + long unsigned int _3; + int * _4; + int _24; + __SIZETYPE__ _6; + __SIZETYPE__ _7; + int * _8; + int _9; + int _13; + unsigned int _30; + unsigned int _31; + + __BB(2,guessed_local(16535624)): + goto __BB3(precise(134217728)); + + __BB(3,loop_header(1),guessed_local(1057206200)): + sum1_5 = __PHI (__BB5: sum1_18, __BB2: 0); + sum2_26 = __PHI (__BB5: sum2_19, __BB2: 0); + i_28 = __PHI (__BB5: i_20, __BB2: 0); + _31 = __PHI (__BB5: _30, __BB2: 64u); + _1 = i_28 * 2; + _2 = (long unsigned int) _1; + _3 = _2 * 4ul; + _4 = r_17(D) + _3; + _24 = __MEM <int> (_4); + /* Deliberately have swapped operands here */ + sum1_18 = sum1_5 + _24; + _13 = _1 + 1; + _6 = (__SIZETYPE__) _13; + _7 = _6 * 4ul; + _8 = r_17(D) + _7; + _9 = __MEM <int> (_8); + /* versus here. */ + sum2_19 = _9 + sum2_26; + i_20 = i_28 + 1; + _30 = _31 - 1u; + if (_30 != 0u) + goto __BB5(guessed(132118446)); + else + goto __BB4(guessed(2099282)); + + __BB(5,guessed_local(1040670576)): + goto __BB3(precise(134217728)); + + __BB(4,guessed_local(16535624)): + sum1_33 = __PHI (__BB3: sum1_18); + sum2_32 = __PHI (__BB3: sum2_19); + q[0] = sum1_33; + q[1] = sum2_32; + return; +} + +/* { dg-final { scan-tree-dump "SLP discovery of size 2 reduction group succeeded" "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/slp-reduc-14.c b/gcc/testsuite/gcc.dg/vect/slp-reduc-14.c new file mode 100644 index 0000000..7966d23 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/slp-reduc-14.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-additional-options "--param vect-epilogues-nomask=0" } */ + +void foo (int * __restrict sums, int *a, int *b, int n) +{ + for (int i = 0; i < n; ++i) + { + sums[0] = sums[0] + a[2*i]; + sums[1] = sums[1] + a[2*i+1]; + sums[2] = sums[2] + b[2*i]; + sums[3] = sums[3] + b[2*i+1]; + } +} + +/* { dg-final { scan-tree-dump-times "SLP discovery of size 2 reduction group" 2 "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/slp-widen-mult-half.c b/gcc/testsuite/gcc.dg/vect/slp-widen-mult-half.c index b69ade3..72811eb 100644 --- a/gcc/testsuite/gcc.dg/vect/slp-widen-mult-half.c +++ b/gcc/testsuite/gcc.dg/vect/slp-widen-mult-half.c @@ -1,7 +1,6 @@ /* Disabling epilogues until we find a better way to deal with scans. */ /* { dg-additional-options "--param vect-epilogues-nomask=0" } */ /* { dg-require-effective-target vect_int } */ -/* { dg-additional-options "-mlasx" { target loongarch*-*-* } } */ #include "tree-vect.h" diff --git a/gcc/testsuite/gcc.dg/vect/tree-vect.h b/gcc/testsuite/gcc.dg/vect/tree-vect.h index 1e4b56e..37908c9 100644 --- a/gcc/testsuite/gcc.dg/vect/tree-vect.h +++ b/gcc/testsuite/gcc.dg/vect/tree-vect.h @@ -76,6 +76,8 @@ check_vect (void) } #elif defined(__mips_msa) asm volatile ("or.v $w0,$w0,$w0"); +#elif defined(__loongarch__) + asm volatile ("vor.v\t$vr0,$vr0,$vr0"); #endif signal (SIGILL, SIG_DFL); } diff --git a/gcc/testsuite/gcc.dg/vect/tsvc/vect-tsvc-s293.c b/gcc/testsuite/gcc.dg/vect/tsvc/vect-tsvc-s293.c index 3213948..34f6af0 100644 --- a/gcc/testsuite/gcc.dg/vect/tsvc/vect-tsvc-s293.c +++ b/gcc/testsuite/gcc.dg/vect/tsvc/vect-tsvc-s293.c @@ -36,4 +36,4 @@ int main (int argc, char **argv) return 0; } -/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { xfail *-*-* } } } */ +/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect"} } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-bool-3.c b/gcc/testsuite/gcc.dg/vect/vect-bool-3.c new file mode 100644 index 0000000..671f602 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-bool-3.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-require-effective-target vect_unpack } */ + +int count_true(const bool *values, int len) +{ + int count = 0; + for (int i = 0; i < len; i++) + count += values[i]; + return count; +} + +/* { dg-final { scan-tree-dump "optimized: loop vectorized" "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_139.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_139.c new file mode 100644 index 0000000..9599493 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_139.c @@ -0,0 +1,37 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#include "tree-vect.h" + +__attribute__((noipa)) +unsigned loop9(unsigned char *a, unsigned n, unsigned c) +{ + for (unsigned j = 0;;) + { + if (c <= j) + __builtin_abort(); + + unsigned char *slot = (unsigned char *)a + j; + + *slot = (char)j; + + unsigned d = j + 1; + if (d < n) + j = d; + else + return d; + } +} + +int main () +{ + check_vect (); + + unsigned char buff[16] = {0}; + unsigned res = loop9 (buff, 16, 20); + if (res != 16) + __builtin_abort (); +} diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_140-pr122868_1.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_140-pr122868_1.c new file mode 100644 index 0000000..80264bd --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_140-pr122868_1.c @@ -0,0 +1,39 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_sizes_16B_8B } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#include "tree-vect.h" + +__attribute__ ((noipa)) +int f (int a[12], int b[12], int n) +{ +#ifdef __arm__ + a = __builtin_assume_aligned (a, 8); + b = __builtin_assume_aligned (b, 8); +#else + a = __builtin_assume_aligned (a, 16); + b = __builtin_assume_aligned (b, 16); +#endif + for (int i = 0; i < n; i++) + { + if (b[i] == 0) + return 0; + if (a[0] > b[i]) + return 1; + } + return 2; +} + +int main () +{ + check_vect (); + + int *a = 0; + int b[12] = {0}; + return f (a, b, 10); +} + +/* { dg-final { scan-tree-dump "not hoisting invariant load due to early break" "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_140-pr122868_2.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_140-pr122868_2.c new file mode 100644 index 0000000..90222fc --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_140-pr122868_2.c @@ -0,0 +1,31 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#include "tree-vect.h" + +__attribute__ ((noipa)) +int f (int a[12], int b[12], int n) +{ + for (int i = 0; i < n; i++) + { + if (b[i] == 0) + return 0; + if (a[0] > b[i]) + return 1; + } + return 2; +} + +int main () +{ + check_vect (); + + int *a = 0; + int b[12] = {0}; + return f (a, b, 10); +} + +/* { dg-final { scan-tree-dump-times "not hoisting invariant load due to early break" 0 "vect" { xfail *-*-* } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_140-pr122868_3.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_140-pr122868_3.c new file mode 100644 index 0000000..670804f --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_140-pr122868_3.c @@ -0,0 +1,39 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_sizes_16B_8B } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#include "tree-vect.h" + +__attribute__ ((noipa)) +int f (int a[12], int b[12], int n) +{ +#ifdef __arm__ + a = __builtin_assume_aligned (a, 8); + b = __builtin_assume_aligned (b, 8); +#else + a = __builtin_assume_aligned (a, 16); + b = __builtin_assume_aligned (b, 16); +#endif + for (int i = 0; i < n; i++) + { + if (a[0] > b[i]) + return 0; + if (b[i] == 0) + return 1; + } + return 2; +} + +int main () +{ + check_vect (); + + int a[12] = {1}; + int b[12] = {0}; + return f (a, b, 10); +} + +/* { dg-final { scan-tree-dump-times "not hoisting invariant load due to early break" 0 "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_140-pr122868_4.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_140-pr122868_4.c new file mode 100644 index 0000000..de2aff2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_140-pr122868_4.c @@ -0,0 +1,31 @@ +/* { dg-add-options vect_early_break } */ +/* { dg-require-effective-target vect_early_break_hw } */ +/* { dg-require-effective-target vect_int } */ + +/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */ + +#include "tree-vect.h" + +__attribute__ ((noipa)) +int f (int a[12], int b[12], int n) +{ + for (int i = 0; i < n; i++) + { + if (a[0] > b[i]) + return 0; + if (b[i] == 0) + return 0; + } + return 2; +} + +int main () +{ + check_vect (); + + int a[12] = {1}; + int b[12] = {0}; + return f (a, b, 10); +} + +/* { dg-final { scan-tree-dump-times "not hoisting invariant load due to early break" 0 "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_39.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_39.c index b3f40b8..bc862ad 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-early-break_39.c +++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_39.c @@ -23,5 +23,6 @@ unsigned test4(unsigned x, unsigned n) return ret; } -/* cannot safely vectorize this due due to the group misalignment. */ -/* { dg-final { scan-tree-dump-times "vectorized 1 loops in function" 0 "vect" } } */ +/* AArch64 will scalarize the load and is able to vectorize it. */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops in function" 1 "vect" { target aarch64*-*-* } } } */ +/* { dg-final { scan-tree-dump-times "vectorized 1 loops in function" 0 "vect" { target { ! aarch64*-*-* } } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-licm-hoist-1.c b/gcc/testsuite/gcc.dg/vect/vect-licm-hoist-1.c new file mode 100644 index 0000000..2e850eb --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-licm-hoist-1.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-additional-options "-fdump-tree-lim2-details -fdump-tree-vect-details" } */ + +/* Test vectorization of "self write" pattern: a[i] = a[0]. + LICM should hoist a[0] by recognizing that even when i==0 causes + aliasing, the stored value equals the loaded value (via SSA). */ + +#define N 32000 + +float a[N]; + +/* Should vectorize. */ + +void +test_safe_hoist (void) +{ + for (int i = 0; i < N; i++) + a[i] = a[0]; +} + +/* { dg-final { scan-tree-dump "loop vectorized" "vect" } } */ +/* { dg-final { scan-tree-dump "independent \\(self write\\)" "lim2" } } */ + diff --git a/gcc/testsuite/gcc.dg/vect/vect-licm-hoist-2.c b/gcc/testsuite/gcc.dg/vect/vect-licm-hoist-2.c new file mode 100644 index 0000000..c42dc3f --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-licm-hoist-2.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_float } */ +/* { dg-additional-options "-fdump-tree-lim2-details -fdump-tree-vect-details" } */ + +/* Negative test: ensure we don't incorrectly hoist when + a store invalidates the loaded value. */ + +#define N 32000 + +float a[N]; + +/* Should NOT hoist: a[0] = 5.0f breaks the SSA dependency. */ + +void +test_unsafe_hoist (void) +{ + for (int i = 0; i < N; i++) + { + float x = a[0]; + a[i] = x; + a[0] = 5.0f; + } +} + +/* { dg-final { scan-tree-dump-not "independent \\(constant-indexed load" "lim2" } } */ + diff --git a/gcc/testsuite/gcc.dg/vect/vect-pr122844.c b/gcc/testsuite/gcc.dg/vect/vect-pr122844.c new file mode 100644 index 0000000..52da3ec --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-pr122844.c @@ -0,0 +1,34 @@ +#include "tree-vect.h" + +short c = 2; +short l = 6; +unsigned char m; +int k; +int a = -1; +unsigned long long t[2][2]; + +static void b( short c, int k, short l, unsigned m) +{ + for( signed x=0; x<2; x++) + for( int ab=0; ab<k+2; ab++) + a = ({ + int ac = a; + int ad = ({ int ac = l ? m : t[x][0]; + unsigned long long ad = c ? m : t[x][x]; + ac < ad ? ac : ad; }); + + ac < ad ? ac : ad; + }); +} + +int main() +{ + check_vect (); + + long long ag; + b(c,k,l,m); + ag = a; + if (ag != -1) + abort (); +} + diff --git a/gcc/testsuite/gcc.dg/vect/vect-pr123002.c b/gcc/testsuite/gcc.dg/vect/vect-pr123002.c new file mode 100644 index 0000000..3b45c48 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-pr123002.c @@ -0,0 +1,39 @@ +/* { dg-additional-options "-mavx2" { target avx2 } } */ + +#include "tree-vect.h" + +unsigned int enc_table_32[8][3] = { + {513735U, 77223048U, 437087610U }, + {0U, 78508U, 646269101U }, + {0U, 0U, 11997U, }, + {0U, 0U, 0U, }, + {0U, 0U, 0U, }, + {0U, 0U, 0U, }, + {0U, 0U, 0U, }, + {0U, 0U, 0U, }}; + +int __attribute__((noipa)) foo() +{ + unsigned long intermediate[3] = {0}; + + for (unsigned long i = 0UL; i < 8; i++) { + intermediate[0] += 2 * (unsigned long)(enc_table_32)[i][0]; + intermediate[1] += 2 * (unsigned long)(enc_table_32)[i][1]; + intermediate[2] += 2 * (unsigned long)(enc_table_32)[i][2]; + } + + if (intermediate[0] == 0xfad8e && + intermediate[1] == 0x9370e68 && intermediate[2] == 0x8125ca08) { + return 0; + } else { + return 1; + } +} + +int main() +{ + check_vect (); + if (foo ()) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-cond-add-1.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-cond-add-1.c new file mode 100644 index 0000000..1e64df7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-cond-add-1.c @@ -0,0 +1,50 @@ +#include "tree-vect.h" + +char mask[128]; + +double __attribute__((noipa)) +foo (double *a, int n) +{ + double sum = 0.0; + for (int i = 0; i < n; ++i) + { + double val; + if (mask[i]) + val = a[i]; + else + val = -0.0; + sum = sum + val; + } + return sum; +} + +double a[128]; + +int main() +{ + check_vect (); + +#pragma GCC novector + for (int i = 0; i < 128; ++i) + { + a[i] = (i * 7) % 15; + mask[i] = (i + 1) & 4; + } + + double sum = foo (a, 87); + double sum2 = 0.0; +#pragma GCC novector + for (int i = 0; i < 87; ++i) + { + double val; + if (mask[i]) + val = a[i]; + else + val = -0.0; + sum2 = sum2 + val; + } + + if (sum != sum2) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-22.c b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-22.c new file mode 100644 index 0000000..732d2328 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-22.c @@ -0,0 +1,46 @@ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd --param vect-partial-vector-usage=2 -w" } */ +/* { dg-additional-options "-mavx512f" { target avx512f_runtime } } */ +/* { dg-add-options ieee } */ +/* { dg-require-effective-target fenv_exceptions } */ +/* { dg-additional-sources vect-simd-clone-22a.c linkonly } */ + +#include <fenv.h> +#include "tree-vect.h" + +#pragma omp declare simd simdlen(16) inbranch +float __attribute__((const)) baz (float x, float y); + +float a[1024]; +int c[1024]; + +void __attribute__((noipa)) +foo (int n, float * __restrict b) +{ + for (int i = 0; i < n; ++i) + { + float aa = a[i]; + float bb = b[i]; + if (c[i] == 0) + aa = baz (aa, bb); + a[i] = aa; + } +} + +float b[1024]; + +int main() +{ + check_vect (); + +#pragma GCC novector + for (int i = 0; i < 1020; ++i) + a[i] = b[i] = 2; + foo (1020, b); + if (fetestexcept (FE_DIVBYZERO) || fetestexcept (FE_INVALID)) + abort (); +#pragma GCC novector + for (int i = 0; i < 1020; ++i) + if (a[i] != 1) + abort (); +} diff --git a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-22a.c b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-22a.c new file mode 100644 index 0000000..88bda07 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-22a.c @@ -0,0 +1,7 @@ +/* { dg-do compile } */ + +#pragma omp declare simd simdlen(16) inbranch +float baz (float x, float y) +{ + return x / y; +} diff --git a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-23.c b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-23.c new file mode 100644 index 0000000..b673ee0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-23.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd -w" } */ +/* { dg-additional-options "-mavx512bw" { target avx512bw } } */ + +#pragma omp declare simd simdlen(32) inbranch +int __attribute__((const)) baz (int x); + +short a[1024]; + +void __attribute__((noipa)) +foo (int n, int * __restrict b) +{ + for (int i = 0; i < n; ++i) + if (a[i]) + b[i] = baz (b[i]); +} diff --git a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-24.c b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-24.c new file mode 100644 index 0000000..5281dfa --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-24.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */ +/* { dg-require-effective-target vect_simd_clones } */ +/* { dg-additional-options "-fopenmp-simd --param vect-partial-vector-usage=1 -fdump-tree-dce6 -w" } */ +/* { dg-additional-options "-mavx512f -mprefer-vector-width=512" { target avx512f } } */ + +#pragma omp declare simd simdlen(16) +int __attribute__((const)) baz (int x); + +int a[1024]; + +void foo (int n, int * __restrict b) +{ + for (int i = 0; i < n; ++i) + if (baz (a[i])) + b[i] = baz (b[i]); +} + +/* One notinbranch SIMD call, one inbranch in the main vector loop and two + inbranch in the masked epilog. */ +/* { dg-final { scan-tree-dump-times "simdclone\.\[0-9\] \\\(\[^,\]\+\\\)" 1 "dce6" { target avx512f } } } */ +/* { dg-final { scan-tree-dump-times "simdclone\.\[0-9\] \\\(\[^,\]\+,\[^,\]\+\\\)" 3 "dce6" { target avx512f } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-widen-mult-const-s16.c b/gcc/testsuite/gcc.dg/vect/vect-widen-mult-const-s16.c index 53c9b84..dfbb217 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-widen-mult-const-s16.c +++ b/gcc/testsuite/gcc.dg/vect/vect-widen-mult-const-s16.c @@ -2,7 +2,6 @@ /* { dg-additional-options "--param vect-epilogues-nomask=0" } */ /* { dg-require-effective-target vect_int } */ /* { dg-additional-options "-fno-ipa-icf" } */ -/* { dg-additional-options "-mlasx" { target loongarch*-*-*} } */ #include "tree-vect.h" diff --git a/gcc/testsuite/gcc.dg/vect/vect-widen-mult-const-u16.c b/gcc/testsuite/gcc.dg/vect/vect-widen-mult-const-u16.c index e9db828..c2ad58f 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-widen-mult-const-u16.c +++ b/gcc/testsuite/gcc.dg/vect/vect-widen-mult-const-u16.c @@ -2,7 +2,6 @@ /* { dg-additional-options "--param vect-epilogues-nomask=0" } */ /* { dg-require-effective-target vect_int } */ /* { dg-additional-options "-fno-ipa-icf" } */ -/* { dg-additional-options "-mlasx" { target loongarch*-*-*} } */ #include "tree-vect.h" diff --git a/gcc/testsuite/gcc.dg/vect/vect-widen-mult-half-u8.c b/gcc/testsuite/gcc.dg/vect/vect-widen-mult-half-u8.c index 607f317..bfdcbaa 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-widen-mult-half-u8.c +++ b/gcc/testsuite/gcc.dg/vect/vect-widen-mult-half-u8.c @@ -2,7 +2,6 @@ /* { dg-additional-options "--param vect-epilogues-nomask=0" } */ /* { dg-require-effective-target vect_int } */ /* { dg-additional-options "-fno-ipa-icf" } */ -/* { dg-additional-options "-mlasx" { target loongarch*-*-*} } */ #include "tree-vect.h" diff --git a/gcc/testsuite/gcc.dg/vect/vect-widen-mult-half.c b/gcc/testsuite/gcc.dg/vect/vect-widen-mult-half.c index cd13d82..e46b0cc 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-widen-mult-half.c +++ b/gcc/testsuite/gcc.dg/vect/vect-widen-mult-half.c @@ -1,7 +1,6 @@ /* Disabling epilogues until we find a better way to deal with scans. */ /* { dg-additional-options "--param vect-epilogues-nomask=0" } */ /* { dg-require-effective-target vect_int } */ -/* { dg-additional-options "-mlasx" { target loongarch*-*-*} } */ #include "tree-vect.h" diff --git a/gcc/testsuite/gcc.dg/vect/vect-widen-mult-u16.c b/gcc/testsuite/gcc.dg/vect/vect-widen-mult-u16.c index 258d253..14411ef 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-widen-mult-u16.c +++ b/gcc/testsuite/gcc.dg/vect/vect-widen-mult-u16.c @@ -1,7 +1,6 @@ /* Disabling epilogues until we find a better way to deal with scans. */ /* { dg-additional-options "--param vect-epilogues-nomask=0" } */ /* { dg-require-effective-target vect_int } */ -/* { dg-additional-options "-mlasx" { target loongarch*-*-*} } */ #include <stdarg.h> #include "tree-vect.h" diff --git a/gcc/testsuite/gcc.dg/vect/vect-widen-mult-u8-s16-s32.c b/gcc/testsuite/gcc.dg/vect/vect-widen-mult-u8-s16-s32.c index 3baafca..f40def5 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-widen-mult-u8-s16-s32.c +++ b/gcc/testsuite/gcc.dg/vect/vect-widen-mult-u8-s16-s32.c @@ -1,7 +1,6 @@ /* Disabling epilogues until we find a better way to deal with scans. */ /* { dg-additional-options "--param vect-epilogues-nomask=0" } */ /* { dg-require-effective-target vect_int } */ -/* { dg-additional-options "-mlasx" { target loongarch*-*-*} } */ #include <stdarg.h> #include "tree-vect.h" diff --git a/gcc/testsuite/gcc.dg/vect/vect-widen-mult-u8-u32.c b/gcc/testsuite/gcc.dg/vect/vect-widen-mult-u8-u32.c index bcfbe19..6386639 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-widen-mult-u8-u32.c +++ b/gcc/testsuite/gcc.dg/vect/vect-widen-mult-u8-u32.c @@ -1,6 +1,5 @@ /* { dg-additional-options "--param vect-epilogues-nomask=0" } */ /* { dg-require-effective-target vect_int } */ -/* { dg-additional-options "-mlasx" { target loongarch*-*-* } } */ #include <stdarg.h> #include "tree-vect.h" diff --git a/gcc/testsuite/gcc.dg/vect/vect-widen-mult-u8.c b/gcc/testsuite/gcc.dg/vect/vect-widen-mult-u8.c index e3bf13b..78ad74b 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-widen-mult-u8.c +++ b/gcc/testsuite/gcc.dg/vect/vect-widen-mult-u8.c @@ -1,6 +1,5 @@ /* { dg-additional-options "--param vect-epilogues-nomask=0" } */ /* { dg-require-effective-target vect_int } */ -/* { dg-additional-options "-mlasx" { target loongarch*-*-*} } */ #include <stdarg.h> #include "tree-vect.h" diff --git a/gcc/testsuite/gcc.dg/vla-1.c b/gcc/testsuite/gcc.dg/vla-1.c index d16e73d..2ab2b7a 100644 --- a/gcc/testsuite/gcc.dg/vla-1.c +++ b/gcc/testsuite/gcc.dg/vla-1.c @@ -16,11 +16,12 @@ main () { volatile int j; int x = 5; + asm volatile ("" : "+r" (x)); j = f1 (x); + asm volatile ("" : "+r" (x)); return 0; } /* One debug source bind is generated for the parameter, and one to describe the sizes of a and b. */ /* { dg-final { scan-tree-dump-times " s=> i" 2 "optimized" } } */ - diff --git a/gcc/testsuite/gcc.dg/vla-init-4.c b/gcc/testsuite/gcc.dg/vla-init-4.c index 06351d0..7d1aa5b 100644 --- a/gcc/testsuite/gcc.dg/vla-init-4.c +++ b/gcc/testsuite/gcc.dg/vla-init-4.c @@ -4,4 +4,4 @@ /* { dg-options "" } */ const int i = 1; -void foo() { char *p = (char [i]){ "" }; } /* { dg-error "compound literal has variable size" } */ +void foo() { char *p = (char [i]){ "" }; } /* { dg-error "variable-sized object" } */ diff --git a/gcc/testsuite/gcc.dg/vla-init-5.c b/gcc/testsuite/gcc.dg/vla-init-5.c index aa9f491..2c249ec 100644 --- a/gcc/testsuite/gcc.dg/vla-init-5.c +++ b/gcc/testsuite/gcc.dg/vla-init-5.c @@ -4,4 +4,4 @@ /* { dg-options "" } */ const int i = 1; -void foo() { void *p = (char [][i]){ "" }; } /* { dg-error "compound literal has variable size" } */ +void foo() { void *p = (char [][i]){ "" }; } /* { dg-error "variable-sized object" } */ |
