libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-prof / val-prof-7.c
blob5ddb1a88c29396b661848e67c5f3bbb813c99cd0
1 /* { dg-options "-O2 -fdump-ipa-profile-optimized -mtune=core2" } */
2 /* { dg-skip-if "" { ! { i?86-*-* x86_64-*-* } } } */
4 char *buffer1;
5 char *buffer2;
7 /* Bzero is not tested because it gets transformed into memset. */
9 #define DEFINE_TEST(N) \
10 __attribute__((noinline)) \
11 void memcpy_test_ ## N (int len) \
12 { \
13 __builtin_memcpy (buffer1, buffer2, len); \
14 } \
16 __attribute__((noinline)) \
17 void mempcpy_test_ ## N (int len) \
18 { \
19 __builtin_mempcpy (buffer1, buffer2, len); \
20 } \
22 __attribute__((noinline)) \
23 void memset_test_ ## N (int len) \
24 { \
25 __builtin_memset (buffer1, 'c', len); \
26 } \
27 __attribute__((noinline)) \
28 void memmove_test_ ## N (int len) \
29 { \
30 __builtin_memmove (buffer1, buffer2, len); \
31 } \
33 void test_stringops_ ## N(int len) \
34 { \
35 memcpy_test_## N (len); \
36 mempcpy_test_ ## N (len); \
37 memset_test_ ## N (len); \
38 memmove_test_ ## N (len); \
39 } \
41 void test_stringops_with_values_ ## N (int common, int not_common) \
42 { \
43 int i; \
44 for (i = 0; i < 1000; i++) \
45 { \
46 if (i > 990) \
47 test_stringops_ ## N (not_common); \
48 else \
49 test_stringops_ ## N (common); \
50 } \
53 DEFINE_TEST(0);
54 DEFINE_TEST(1);
55 DEFINE_TEST(2);
57 int main() {
58 buffer1 = __builtin_malloc (1000);
59 buffer2 = __builtin_malloc (1000);
61 test_stringops_with_values_0 (8, 55);
62 test_stringops_with_values_1 (55, 55);
63 test_stringops_with_values_2 (257, 55);
65 return 0;
68 /* { dg-final-use-not-autofdo { scan-ipa-dump "Transformation done: single value 8 stringop for BUILT_IN_MEMCPY" "profile" } } */
69 /* { dg-final-use-not-autofdo { scan-ipa-dump "Transformation done: single value 55 stringop for BUILT_IN_MEMCPY" "profile" } } */
70 /* { dg-final-use-not-autofdo { scan-ipa-dump-times "Transformation done: single value 32 stringop for BUILT_IN_MEMCPY" 0 "profile" } } */
72 /* { dg-final-use-not-autofdo { scan-ipa-dump "Transformation done: single value 8 stringop for BUILT_IN_MEMPCPY" "profile" } } */
73 /* { dg-final-use-not-autofdo { scan-ipa-dump "Transformation done: single value 55 stringop for BUILT_IN_MEMPCPY" "profile" } } */
74 /* { dg-final-use-not-autofdo { scan-ipa-dump-times "Transformation done: single value 32 stringop for BUILT_IN_MEMPCPY" 0 "profile" } } */
76 /* { dg-final-use-not-autofdo { scan-ipa-dump "Transformation done: single value 8 stringop for BUILT_IN_MEMSET" "profile" } } */
77 /* { dg-final-use-not-autofdo { scan-ipa-dump "Transformation done: single value 55 stringop for BUILT_IN_MEMSET" "profile" } } */
78 /* { dg-final-use-not-autofdo { scan-ipa-dump-times "Transformation done: single value 32 stringop for BUILT_IN_MEMSET" 0 "profile" } } */
80 /* { dg-final-use-not-autofdo { scan-ipa-dump "Transformation done: single value 8 stringop for BUILT_IN_MEMMOVE" "profile" } } */
81 /* { dg-final-use-not-autofdo { scan-ipa-dump "Transformation done: single value 55 stringop for BUILT_IN_MEMMOVE" "profile" } } */
82 /* { dg-final-use-not-autofdo { scan-ipa-dump-times "Transformation done: single value 32 stringop for BUILT_IN_MEMMOVE" 0 "profile" } } */