1module &__llvm_hsail_module:1:0:$full:$large:$near; 2 3/* Regression test for a private array access case which used to assert. */ 4 5/* { dg-do compile } */ 6/* { dg-options "-fdump-tree-gimple" } */ 7 8decl prog function &vec_sum()( 9 arg_u32 %a, 10 arg_u32 %b, 11 arg_u32 %res, 12 arg_u32 %N); 13 14prog function &vec_sum()( 15 arg_u32 %a, 16 arg_u32 %b, 17 arg_u32 %res, 18 arg_u32 %N) 19{ 20 21 ld_arg_align(4)_u32 $s0, [%N]; 22 ld_arg_align(4)_u32 $s1, [%res]; 23 ld_arg_align(4)_u32 $s2, [%b]; 24 ld_arg_align(4)_u32 $s3, [%a]; 25 cmp_le_b1_s32 $c0, $s0, 0; 26 cbr_b1 $c0, @BB0_2; 27@BB0_1: 28 ld_private_align(4)_u32 $s4, [$s3]; 29 ld_private_align(4)_u32 $s5, [$s2]; 30 add_u32 $s4, $s5, $s4; 31 st_private_align(4)_u32 $s4, [$s1]; 32 add_u32 $s1, $s1, 4; 33 add_u32 $s2, $s2, 4; 34 add_u32 $s3, $s3, 4; 35 add_u32 $s0, $s0, 4294967295; 36 cmp_ne_b1_s32 $c0, $s0, 0; 37 cbr_b1 $c0, @BB0_1; 38@BB0_2: 39 ret; 40}; 41 42prog kernel &test( 43 kernarg_u64 %in, 44 kernarg_u64 %out) 45{ 46 47 align(4) private_u8 %__privateStack[1200]; 48 mov_b64 $d1, 0; 49/* This used to crash when gcc asserts enabled: */ 50 lda_private_u32 $s0, [%__privateStack][400]; 51 lda_private_u32 $s1, [%__privateStack]; 52 ld_kernarg_align(8)_width(all)_u64 $d0, [%out]; 53 ld_kernarg_align(8)_width(all)_u64 $d2, [%in]; 54@BB1_1: 55 add_u64 $d3, $d2, $d1; 56 ld_global_align(4)_u32 $s2, [$d3]; 57 st_private_align(4)_u32 $s2, [$s0]; 58 st_private_align(4)_u32 $s2, [$s1]; 59 add_u32 $s1, $s1, 4; 60 add_u32 $s0, $s0, 4; 61 add_u64 $d1, $d1, 4; 62 cmp_ne_b1_s64 $c0, $d1, 400; 63 cbr_b1 $c0, @BB1_1; 64 mov_b32 $s1, 0; 65 lda_private_u32 $s0, [%__privateStack][800]; 66@BB1_3: 67 ld_private_align(4)_u32 $s2, [%__privateStack][$s1]; 68 ld_private_align(4)_u32 $s3, [%__privateStack][$s1+400]; 69 add_u32 $s2, $s3, $s2; 70 st_private_align(4)_u32 $s2, [%__privateStack][$s1+800]; 71 add_u32 $s1, $s1, 4; 72 cmp_ne_b1_s32 $c0, $s1, 400; 73 cbr_b1 $c0, @BB1_3; 74 mov_b64 $d1, 0; 75@BB1_5: 76 add_u64 $d2, $d0, $d1; 77 ld_private_align(4)_u32 $s1, [$s0]; 78 st_global_align(4)_u32 $s1, [$d2]; 79 add_u32 $s0, $s0, 4; 80 add_u64 $d1, $d1, 4; 81 cmp_ne_b1_s64 $c0, $d1, 400; 82 cbr_b1 $c0, @BB1_5; 83 ret; 84}; 85 86/* br @skip converted to a goto */ 87/* { dg-final { scan-tree-dump "= \\\(void \\\*\\\) priv_var_offset" "gimple"} } */ 88