]>
git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.dg/tree-ssa/pr96789.c
1 /* { dg-do compile } */
2 /* Disable loop vectorization to avoid that loop vectorizer
3 optimizes those two loops that operate tmp array so that
4 subsequent dse3 won't eliminate expected tmp stores. */
5 /* { dg-options "-O2 -funroll-loops -ftree-slp-vectorize -fno-tree-loop-vectorize -fdump-tree-dse-details" } */
7 /* Test if scalar cleanup pass takes effects, mainly check
8 its secondary pass DSE can remove dead stores on array
14 foo (int16_t *diff
, int i_size
, uint8_t *val1
, int i_val1
, uint8_t *val2
,
17 for (int y
= 0; y
< i_size
; y
++)
19 for (int x
= 0; x
< i_size
; x
++)
20 diff
[x
+ y
* i_size
] = val1
[x
] - val2
[x
];
27 bar (int16_t res
[16], uint8_t *val1
, uint8_t *val2
)
32 foo (d
, 4, val1
, 16, val2
, 32);
34 for (int i
= 0; i
< 4; i
++)
36 int s03
= d
[i
* 4 + 0] + d
[i
* 4 + 3];
37 int s12
= d
[i
* 4 + 1] + d
[i
* 4 + 2];
38 int d03
= d
[i
* 4 + 0] - d
[i
* 4 + 3];
39 int d12
= d
[i
* 4 + 1] - d
[i
* 4 + 2];
41 tmp
[0 * 4 + i
] = s03
+ s12
;
42 tmp
[1 * 4 + i
] = 2 * d03
+ d12
;
43 tmp
[2 * 4 + i
] = s03
- s12
;
44 tmp
[3 * 4 + i
] = d03
- 2 * d12
;
47 for (int i
= 0; i
< 4; i
++)
49 int s03
= tmp
[i
* 4 + 0] + tmp
[i
* 4 + 3];
50 int s12
= tmp
[i
* 4 + 1] + tmp
[i
* 4 + 2];
51 int d03
= tmp
[i
* 4 + 0] - tmp
[i
* 4 + 3];
52 int d12
= tmp
[i
* 4 + 1] - tmp
[i
* 4 + 2];
54 res
[i
* 4 + 0] = s03
+ s12
;
55 res
[i
* 4 + 1] = 2 * d03
+ d12
;
56 res
[i
* 4 + 2] = s03
- s12
;
57 res
[i
* 4 + 3] = d03
- 2 * d12
;
61 /* { dg-final { scan-tree-dump {Deleted dead store:.*tmp} "dse4" } } */