1 /* { dg-require-effective-target vect_int } */
2 /* { dg-require-effective-target vect_shift } */
3 /* { dg-require-effective-target vect_pack_trunc } */
4 /* { dg-require-effective-target vect_unpack } */
9 #define SIGNEDNESS signed
16 /* Both range analysis and backward propagation from the truncation show
17 that these calculations can be done in SIGNEDNESS short. */
18 void __attribute__ ((noipa
))
19 f (SIGNEDNESS
char *restrict a
, SIGNEDNESS
char *restrict b
,
20 SIGNEDNESS
char *restrict c
)
22 for (int i
= 0; i
< N
; ++i
)
24 /* Deliberate use of signed >>. */
25 int res
= b
[i
] + c
[i
];
26 a
[i
] = (res
+ (res
>> 1)) >> 2;
35 SIGNEDNESS
char a
[N
], b
[N
], c
[N
];
36 for (int i
= 0; i
< N
; ++i
)
38 b
[i
] = BASE_B
+ i
* 5;
39 c
[i
] = BASE_C
+ i
* 4;
40 asm volatile ("" ::: "memory");
44 for (int i
= 0; i
< N
; ++i
)
46 int res
= BASE_B
+ BASE_C
+ i
* 9;
47 if (a
[i
] != ((res
+ (res
>> 1)) >> 2))
54 /* { dg-final { scan-tree-dump {Splitting statement} "vect" } } */
55 /* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* \+ } "vect" } } */
56 /* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 1} "vect" } } */
57 /* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 2} "vect" } } */
58 /* { dg-final { scan-tree-dump {vect_recog_cast_forwprop_pattern: detected:[^\n]* \(signed char\)} "vect" } } */
59 /* { dg-final { scan-tree-dump-not {vector[^ ]* int} "vect" } } */
60 /* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" } } */