1 /* { dg-do compile } */
2 /* { dg-options "-O3 -march=zEC12 -mzarch" } */
5 foo1 (unsigned long a
, unsigned long b
)
7 return (a
<< 5) | (b
& (((1UL << 5) - 1)));
10 /* This generates very different RTX than foo1. The output reg (r2)
11 matches the unshifted argument. So it actually is a
12 (set (zero_extract a 59 0) b) */
14 foo2 (unsigned long a
, unsigned long b
)
16 return (b
<< 5) | (a
& (((1UL << 5) - 1)));
19 /* risbgn cannot be used when less bits are removed with the mask. */
22 foo1b (unsigned long a
, unsigned long b
)
24 return (a
<< 5) | (b
& 1);
28 foo2b (unsigned long a
, unsigned long b
)
30 return (b
<< 5) | (a
& 1);
33 /* risbgn cannot be used when the masked bits would end up in the
34 result since a real OR is required then. */
36 foo1c (unsigned long a
, unsigned long b
)
38 return (a
<< 5) | (b
& 127);
42 foo2c (unsigned long a
, unsigned long b
)
44 return (b
<< 5) | (a
& 127);
48 foo3 (unsigned long a
, unsigned long b
)
51 return (a
<< 5) | (b
>> 59);
53 return (a
<< 5) | (b
>> 27);
58 foo4 (unsigned long a
, unsigned long b
)
61 return (b
<< 5) | (a
>> 59);
63 return (b
<< 5) | (a
>> 27);
67 /* risbgn can be used also if there are some bits spared in the middle
70 foo3b (unsigned long a
, unsigned long b
)
73 return (a
<< 6) | (b
>> 59);
75 return (a
<< 6) | (b
>> 27);
80 foo4b (unsigned long a
, unsigned long b
)
83 return (b
<< 6) | (a
>> 59);
85 return (b
<< 6) | (a
>> 27);
89 /* One bit of overlap so better don't use risbgn. */
92 foo3c (unsigned long a
, unsigned long b
)
95 return (a
<< 4) | (b
>> 59);
97 return (a
<< 4) | (b
>> 27);
102 foo4c (unsigned long a
, unsigned long b
)
105 return (b
<< 4) | (a
>> 59);
107 return (b
<< 4) | (a
>> 27);
111 /* The functions foo3, foo4, foo3b, foo4b no longer use risbgn but rosbg instead
112 which is slightly worse. Combine prefers to use the simpler two insn
113 combinations possible with rosbg instead of the more complicated three insn
114 combinations that result in risbgn. This problem has been introduced with
117 S/390: Add patterns for r<nox>sbg instructions.
119 (3rd of May, 2016). This should be fixed some time in the future, but for
120 now just adapt the expected result:
122 { dg-final { scan-assembler-times "risbgn" 6 { xfail { *-*-* } } } }
123 { dg-final { scan-assembler-times "risbgn" 2 } }