]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.dg/tree-ssa/pr96789.c
Fix profile update in tree_transform_and_unroll_loop
[thirdparty/gcc.git] / 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" } */
6
7 /* Test if scalar cleanup pass takes effects, mainly check
8 its secondary pass DSE can remove dead stores on array
9 tmp. */
10
11 #include "stdint.h"
12
13 static inline void
14 foo (int16_t *diff, int i_size, uint8_t *val1, int i_val1, uint8_t *val2,
15 int i_val2)
16 {
17 for (int y = 0; y < i_size; y++)
18 {
19 for (int x = 0; x < i_size; x++)
20 diff[x + y * i_size] = val1[x] - val2[x];
21 val1 += i_val1;
22 val2 += i_val2;
23 }
24 }
25
26 void
27 bar (int16_t res[16], uint8_t *val1, uint8_t *val2)
28 {
29 int16_t d[16];
30 int16_t tmp[16];
31
32 foo (d, 4, val1, 16, val2, 32);
33
34 for (int i = 0; i < 4; i++)
35 {
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];
40
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;
45 }
46
47 for (int i = 0; i < 4; i++)
48 {
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];
53
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;
58 }
59 }
60
61 /* { dg-final { scan-tree-dump {Deleted dead store:.*tmp} "dse4" } } */