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, with "res"
18 being extended for the store to d[i]. */
19 void __attribute__ ((noipa
))
20 f (SIGNEDNESS
char *restrict a
, SIGNEDNESS
char *restrict b
,
21 SIGNEDNESS
char *restrict c
, int *restrict d
)
23 for (int i
= 0; i
< N
; ++i
)
25 /* Deliberate use of signed >>. */
26 int res
= b
[i
] + c
[i
];
27 a
[i
] = (res
+ (res
>> 1)) >> 2;
37 SIGNEDNESS
char a
[N
], b
[N
], c
[N
];
39 for (int i
= 0; i
< N
; ++i
)
41 b
[i
] = BASE_B
+ i
* 5;
42 c
[i
] = BASE_C
+ i
* 4;
43 asm volatile ("" ::: "memory");
47 for (int i
= 0; i
< N
; ++i
)
49 int res
= BASE_B
+ BASE_C
+ i
* 9;
50 if (a
[i
] != ((res
+ (res
>> 1)) >> 2))
59 /* { dg-final { scan-tree-dump {Splitting statement} "vect" } } */
60 /* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* \+ } "vect" } } */
61 /* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 1} "vect" } } */
62 /* { dg-final { scan-tree-dump {vect_recog_over_widening_pattern: detected:[^\n]* >> 2} "vect" } } */
63 /* { dg-final { scan-tree-dump {vect_recog_cast_forwprop_pattern: detected:[^\n]* \(signed char\)} "vect" } } */
64 /* { dg-final { scan-tree-dump {vector[^ ]* int} "vect" } } */
65 /* { dg-final { scan-tree-dump-times "vectorized 1 loop" 1 "vect" } } */