1 /* PR tree-optimization/77357 - strlen of constant strings not folded
3 { dg-options "-O0 -Wall -fdump-tree-gimple" } */
7 #define CONCAT(x, y) x ## y
8 #define CAT(x, y) CONCAT (x, y)
9 #define FAILNAME(name, counter) \
10 CAT (CAT (CAT (call_ ## name ##_on_line_, __LINE__), _), counter)
12 #define FAIL(name, counter) do { \
13 extern void FAILNAME (name, counter) (void); \
14 FAILNAME (name, counter)(); \
17 /* Macro to emit a call to funcation named
18 call_in_true_branch_not_eliminated_on_line_NNN()
19 for each call that's expected to be eliminated. The dg-final
20 scan-tree-dump-time directive at the bottom of the test verifies
21 that no such call appears in output. */
23 if (!(expr)) FAIL (in_true_branch_not_eliminated, __COUNTER__); else (void)0
25 #define T(s, n) ELIM (strlen (s) == n)
30 char a1
[1], a2
[2], a3
[3], a4
[4], a5
[5], a6
[6], a7
[7], a8
[8], a9
[9];
43 const char a9
[][9] = { S0
, S1
, S2
, S3
, S4
, S5
, S6
, S7
, S8
};
45 void test_elim_a9 (unsigned i
)
47 ELIM (strlen (&a9
[0][i
]) > 0);
48 ELIM (strlen (&a9
[1][i
]) > 1);
49 ELIM (strlen (&a9
[2][i
]) > 2);
50 ELIM (strlen (&a9
[3][i
]) > 3);
51 ELIM (strlen (&a9
[4][i
]) > 4);
52 ELIM (strlen (&a9
[5][i
]) > 5);
53 ELIM (strlen (&a9
[6][i
]) > 6);
54 ELIM (strlen (&a9
[7][i
]) > 7);
55 ELIM (strlen (&a9
[8][i
]) > 8);
58 const char a9_9
[][9][9] = {
59 { S0
, S1
, S2
, S3
, S4
, S5
, S6
, S7
, S8
},
60 { S1
, S2
, S3
, S4
, S5
, S6
, S7
, S8
, S0
},
61 { S2
, S3
, S4
, S5
, S6
, S7
, S8
, S0
, S1
},
62 { S3
, S4
, S5
, S6
, S7
, S8
, S0
, S1
, S2
},
63 { S4
, S5
, S6
, S7
, S8
, S0
, S1
, S2
, S3
},
64 { S5
, S6
, S7
, S8
, S0
, S1
, S2
, S3
, S4
},
65 { S6
, S7
, S8
, S0
, S1
, S2
, S3
, S4
, S5
},
66 { S7
, S8
, S0
, S1
, S2
, S3
, S4
, S5
, S6
},
67 { S8
, S0
, S1
, S2
, S3
, S4
, S5
, S6
, S7
}
70 void test_elim_a9_9 (unsigned i
)
74 ELIM (strlen (&a9_9[I][0][i]) > (0 + I) % 9); \
75 ELIM (strlen (&a9_9[I][1][i]) > (1 + I) % 9); \
76 ELIM (strlen (&a9_9[I][2][i]) > (2 + i) % 9); \
77 ELIM (strlen (&a9_9[I][3][i]) > (3 + I) % 9); \
78 ELIM (strlen (&a9_9[I][4][i]) > (4 + I) % 9); \
79 ELIM (strlen (&a9_9[I][5][i]) > (5 + I) % 9); \
80 ELIM (strlen (&a9_9[I][6][i]) > (6 + I) % 9); \
81 ELIM (strlen (&a9_9[I][7][i]) > (7 + I) % 9); \
82 ELIM (strlen (&a9_9[I][8][i]) > (8 + I) % 9)
84 T (0); T (1); T (2); T (3); T (4); T (5); T (6); T (7); T (8);
87 /* { dg-final { scan-tree-dump-times "strlen1" 0 "gimple" } } */