PR tree-optimization/33562
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / slsr-8.c
blob585b660886b51bfbbb1f1b0e748ea040fd7670ba
1 /* Verify straight-line strength reduction for simple pointer subtraction. */
3 /* { dg-do compile } */
4 /* { dg-options "-O3 -fdump-tree-optimized" } */
6 int*
7 f (int s, int *c, int *d)
9 int a1, a2, a3, *x1, *x2, *x3;
11 a1 = 2 * s;
12 x1 = c - a1;
13 a2 = 4 * s;
14 x2 = c - a2;
15 a3 = 6 * s;
16 x3 = c - a3;
17 return x1 == d ? x2 : x3;
20 /* Note that since some branch prediction heuristics changed, the
21 calculations of x2 and x3 are pushed downward into the legs
22 of the conditional, changing the code presented to SLSR.
23 However, this proves to be a useful test for introducing an
24 initializer with a cast, so we'll keep it as is. */
26 /* There are 4 ' * ' instances in the decls (since "int * iftmp.0;" is
27 added), 2 parms, 3 in the code. The second one in the code may
28 be a widening multiply (for example, on AArch64). */
29 /* { dg-final { scan-tree-dump-times " w?\\* " 9 "optimized" } } */