From c7488b4ffb7b91c9fe9b2eeddda30f818351f535 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pekka=20J=C3=A4=C3=A4skel=C3=A4inen?= Date: Sat, 13 May 2017 11:57:16 +0000 Subject: [PATCH] BRIG FE: Fix an assertion when doing an 'lda' of a private array offset. From-SVN: r248006 --- gcc/brig/ChangeLog | 9 +- .../brigfrontend/brig-code-entry-handler.cc | 6 +- gcc/testsuite/ChangeLog | 6 ++ .../gimple/priv-array-offset-access.hsail | 87 +++++++++++++++++++ 4 files changed, 105 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/brig.dg/test/gimple/priv-array-offset-access.hsail diff --git a/gcc/brig/ChangeLog b/gcc/brig/ChangeLog index 338873e8cac..3c563b1a0e2 100644 --- a/gcc/brig/ChangeLog +++ b/gcc/brig/ChangeLog @@ -1,4 +1,11 @@ -2017-05-03 Pekka Jääskeläinen +2017-05-13 Pekka Jääskeläinen + + * brigfrontend/brig-code-entry-handler.cc + (brig_code_entry_handler::build_address_operand): Fix + an assertion when doing an 'lda' of a private array + offset. + +2017-05-03 Pekka Jääskeläinen * brigfrontend/brig-code-entry-handler.cc (brig_code_entry_handler::build_address_operand): Fix a bug diff --git a/gcc/brig/brigfrontend/brig-code-entry-handler.cc b/gcc/brig/brigfrontend/brig-code-entry-handler.cc index 3abd80e241a..906f47e76b3 100644 --- a/gcc/brig/brigfrontend/brig-code-entry-handler.cc +++ b/gcc/brig/brigfrontend/brig-code-entry-handler.cc @@ -486,8 +486,10 @@ brig_code_entry_handler::build_address_operand addr = const_offset_2; else addr = build2 (POINTER_PLUS_EXPR, ptr_type_node, - addr, convert (size_type_node, const_offset_2)); - + /* Addr can be a constant offset in case this is + a private array access. */ + convert (ptr_type_node, addr), + convert (size_type_node, const_offset_2)); } gcc_assert (addr != NULL_TREE); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e1e7c42366f..c7e2dec9681 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2017-05-13 Pekka Jääskeläinen + + * brig.dg/test/gimple/priv-array-offset-access.hsail: + A regression test for a private array access case which caused + an assert. + 2017-05-12 Martin Sebor PR testsuite/80643 diff --git a/gcc/testsuite/brig.dg/test/gimple/priv-array-offset-access.hsail b/gcc/testsuite/brig.dg/test/gimple/priv-array-offset-access.hsail new file mode 100644 index 00000000000..b20704b2caa --- /dev/null +++ b/gcc/testsuite/brig.dg/test/gimple/priv-array-offset-access.hsail @@ -0,0 +1,87 @@ +module &__llvm_hsail_module:1:0:$full:$large:$near; + +/* Regression test for a private array access case which used to assert. */ + +/* { dg-do compile } */ +/* { dg-options "-fdump-tree-gimple" } */ + +decl prog function &vec_sum()( + arg_u32 %a, + arg_u32 %b, + arg_u32 %res, + arg_u32 %N); + +prog function &vec_sum()( + arg_u32 %a, + arg_u32 %b, + arg_u32 %res, + arg_u32 %N) +{ + + ld_arg_align(4)_u32 $s0, [%N]; + ld_arg_align(4)_u32 $s1, [%res]; + ld_arg_align(4)_u32 $s2, [%b]; + ld_arg_align(4)_u32 $s3, [%a]; + cmp_le_b1_s32 $c0, $s0, 0; + cbr_b1 $c0, @BB0_2; +@BB0_1: + ld_private_align(4)_u32 $s4, [$s3]; + ld_private_align(4)_u32 $s5, [$s2]; + add_u32 $s4, $s5, $s4; + st_private_align(4)_u32 $s4, [$s1]; + add_u32 $s1, $s1, 4; + add_u32 $s2, $s2, 4; + add_u32 $s3, $s3, 4; + add_u32 $s0, $s0, 4294967295; + cmp_ne_b1_s32 $c0, $s0, 0; + cbr_b1 $c0, @BB0_1; +@BB0_2: + ret; +}; + +prog kernel &test( + kernarg_u64 %in, + kernarg_u64 %out) +{ + + align(4) private_u8 %__privateStack[1200]; + mov_b64 $d1, 0; +/* This used to crash when gcc asserts enabled: */ + lda_private_u32 $s0, [%__privateStack][400]; + lda_private_u32 $s1, [%__privateStack]; + ld_kernarg_align(8)_width(all)_u64 $d0, [%out]; + ld_kernarg_align(8)_width(all)_u64 $d2, [%in]; +@BB1_1: + add_u64 $d3, $d2, $d1; + ld_global_align(4)_u32 $s2, [$d3]; + st_private_align(4)_u32 $s2, [$s0]; + st_private_align(4)_u32 $s2, [$s1]; + add_u32 $s1, $s1, 4; + add_u32 $s0, $s0, 4; + add_u64 $d1, $d1, 4; + cmp_ne_b1_s64 $c0, $d1, 400; + cbr_b1 $c0, @BB1_1; + mov_b32 $s1, 0; + lda_private_u32 $s0, [%__privateStack][800]; +@BB1_3: + ld_private_align(4)_u32 $s2, [%__privateStack][$s1]; + ld_private_align(4)_u32 $s3, [%__privateStack][$s1+400]; + add_u32 $s2, $s3, $s2; + st_private_align(4)_u32 $s2, [%__privateStack][$s1+800]; + add_u32 $s1, $s1, 4; + cmp_ne_b1_s32 $c0, $s1, 400; + cbr_b1 $c0, @BB1_3; + mov_b64 $d1, 0; +@BB1_5: + add_u64 $d2, $d0, $d1; + ld_private_align(4)_u32 $s1, [$s0]; + st_global_align(4)_u32 $s1, [$d2]; + add_u32 $s0, $s0, 4; + add_u64 $d1, $d1, 4; + cmp_ne_b1_s64 $c0, $d1, 400; + cbr_b1 $c0, @BB1_5; + ret; +}; + +/* br @skip converted to a goto */ +/* { dg-final { scan-tree-dump "= \\\(void \\\*\\\) priv_var_offset" "gimple"} } */ -- 2.30.2