Debian Codegraph @

gcc/testsuite/gcc.dg/tree-ssa/split-path-1.c

raw
1 /* { dg-do run } */
2 /* Note both PHI-OPT and the loop if conversion pass converts the inner if to be branchless using min/max. */
3 /* { dg-options "-O2 -fsplit-paths -fdump-tree-split-paths-details --param max-jump-thread-duplication-stmts=20 -fno-ssa-phiopt -fno-tree-loop-if-convert" } */
4
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <ctype.h>
8
9 #define RGBMAX 255
10
11 unsigned char
12 test()
13 {
14 int i, Pels;
15 int sum = 0;
16 unsigned char xr, xg, xb;
17 unsigned char xc, xm, xy, xk = 0;
18 unsigned char *ReadPtr, *EritePtr;
19
20 ReadPtr = ( unsigned char *) malloc (sizeof (unsigned char) * 100);
21 EritePtr = ( unsigned char *) malloc (sizeof (unsigned char) * 100);
22
23 for (i = 0; i < 100;i++)
24 {
25 ReadPtr[i] = 100 - i;
26 }
27
28 for (i = 0; i < 24; i++)
29 {
30 xr = *ReadPtr++;
31 xg = *ReadPtr++;
32 xb = *ReadPtr++;
33
34 xc = (unsigned char) (RGBMAX - xr);
35 xm = (unsigned char) (RGBMAX - xg);
36 xy = (unsigned char) (RGBMAX - xb);
37
38 if (xc < xm)
39 {
40 xk = (unsigned char) (xc < xy ? xc : xy);
41 }
42 else
43 {
44 xk = (unsigned char) (xm < xy ? xm : xy);
45 }
46
47 xc = (unsigned char) (xc - xk);
48 xm = (unsigned char) (xm - xk);
49 xy = (unsigned char) (xy - xk);
50
51 *EritePtr++ = xc;
52 *EritePtr++ = xm;
53 *EritePtr++ = xy;
54 *EritePtr++ = xk;
55 sum += *(--EritePtr);
56
57 }
58 return sum;
59 }
60
61 int
62 main()
63 {
64 if (test() != 196)
65 abort();
66
67 return 0;
68 }
69
70 /* { dg-final { scan-tree-dump "Duplicating join block" "split-paths" } } */