Debian Codegraph @

gcc/testsuite/gcc.dg/tree-ssa/slsr-40.c

raw
1 /* Verify straight-line strength reduction for array
2 subscripting.
3
4 elems[n-1] is reduced to elems + n * 4 + 0xffffffff * 4, only when
5 pointers are of the same size as that of int (assuming 4 bytes). */
6
7 /* { dg-do run } */
8 /* { dg-options "-O2" } */
9
10 struct data
11 {
12 unsigned long elms[1];
13 } gData;
14
15 void __attribute__((noinline))
16 foo (struct data *dst, unsigned int n)
17 {
18 dst->elms[n - 1] &= 1;
19 }
20
21 int
22 main ()
23 {
24 foo (&gData, 1);
25 return 0;
26 }
27