View | Details | Return to bug 57157 | Differences between
and this patch

Collapse All | Expand All

(-)gcc/tree-ssa-forwprop.c.jj (+241 lines)
Lines 2124-2129 simplify_bitwise_binary (gimple_stmt_ite Link Here
2124
}
2124
}
2125
2125
2126
2126
2127
/* Recognize rotation patterns.  Return true if a transformation
2128
   applied, otherwise return false.
2129
2130
   We are looking for X with unsigned type T with bitsize B, OP being
2131
   +, | or ^, some type T2 wider than T and
2132
   (X << CNT1) OP (X >> CNT2)				iff CNT1 + CNT2 == B
2133
   ((T) ((T2) X << CNT1)) OP ((T) ((T2) X >> CNT2))	iff CNT1 + CNT2 == B
2134
   (X << Y) OP (X >> (B - Y))
2135
   (X << (int) Y) OP (X >> (int) (B - Y))
2136
   ((T) ((T2) X << Y)) OP ((T) ((T2) X >> (B - Y)))
2137
   ((T) ((T2) X << (int) Y)) OP ((T) ((T2) X >> (int) (B - Y)))
2138
   (X << Y) OP (X >> ((-Y) & (B - 1)))
2139
   (X << (int) Y) OP (X >> (int) ((-Y) & (B - 1)))
2140
   ((T) ((T2) X << Y)) OP ((T) ((T2) X >> ((-Y) & (B - 1))))
2141
   ((T) ((T2) X << (int) Y)) OP ((T) ((T2) X >> (int) ((-Y) & (B - 1))))
2142
2143
   and transform these into:
2144
   X r<< CNT1
2145
   X r<< Y
2146
2147
   Note, in the patterns with T2 type, the type of OP operands
2148
   might be even a signed type, but should have precision B.  */
2149
2150
static bool
2151
simplify_rotate (gimple_stmt_iterator *gsi)
2152
{
2153
  gimple stmt = gsi_stmt (*gsi);
2154
  tree arg[2], rtype, rotcnt = NULL_TREE;
2155
  tree def_arg1[2], def_arg2[2];
2156
  enum tree_code def_code[2];
2157
  tree lhs;
2158
  int i;
2159
  bool swapped_p = false;
2160
  gimple g;
2161
2162
  arg[0] = gimple_assign_rhs1 (stmt);
2163
  arg[1] = gimple_assign_rhs2 (stmt);
2164
  rtype = TREE_TYPE (arg[0]);
2165
2166
  /* Only create rotates in complete modes.  Other cases are not
2167
     expanded properly.  */
2168
  if (!INTEGRAL_TYPE_P (rtype)
2169
      || TYPE_PRECISION (rtype) != GET_MODE_PRECISION (TYPE_MODE (rtype)))
2170
    return false;
2171
2172
  for (i = 0; i < 2; i++)
2173
    defcodefor_name (arg[i], &def_code[i], &def_arg1[i], &def_arg2[i]);
2174
2175
  /* Look through narrowing conversions.  */
2176
  if (CONVERT_EXPR_CODE_P (def_code[0])
2177
      && CONVERT_EXPR_CODE_P (def_code[1])
2178
      && INTEGRAL_TYPE_P (TREE_TYPE (def_arg1[0]))
2179
      && INTEGRAL_TYPE_P (TREE_TYPE (def_arg1[1]))
2180
      && TYPE_PRECISION (TREE_TYPE (def_arg1[0]))
2181
	 == TYPE_PRECISION (TREE_TYPE (def_arg1[1]))
2182
      && TYPE_PRECISION (TREE_TYPE (def_arg1[0])) > TYPE_PRECISION (rtype)
2183
      && has_single_use (arg[0])
2184
      && has_single_use (arg[1]))
2185
    {
2186
      for (i = 0; i < 2; i++)
2187
	{
2188
	  arg[i] = def_arg1[i];
2189
	  defcodefor_name (arg[i], &def_code[i], &def_arg1[i], &def_arg2[i]);
2190
	}
2191
    }
2192
2193
  /* One operand has to be LSHIFT_EXPR and one RSHIFT_EXPR.  */
2194
  for (i = 0; i < 2; i++)
2195
    if (def_code[i] != LSHIFT_EXPR && def_code[i] != RSHIFT_EXPR)
2196
      return false;
2197
    else if (!has_single_use (arg[i]))
2198
      return false;
2199
  if (def_code[0] == def_code[1])
2200
    return false;
2201
2202
  /* If we've looked through narrowing conversions before, look through
2203
     widening conversions from unsigned type with the same precision
2204
     as rtype here.  */
2205
  if (TYPE_PRECISION (TREE_TYPE (def_arg1[0])) != TYPE_PRECISION (rtype))
2206
    for (i = 0; i < 2; i++)
2207
      {
2208
	tree tem;
2209
	enum tree_code code;
2210
	defcodefor_name (def_arg1[i], &code, &tem, NULL);
2211
	if (!CONVERT_EXPR_CODE_P (code)
2212
	    || !INTEGRAL_TYPE_P (TREE_TYPE (tem))
2213
	    || TYPE_PRECISION (TREE_TYPE (tem)) != TYPE_PRECISION (rtype))
2214
	  return false;
2215
	def_arg1[i] = tem;
2216
      }
2217
  /* Both shifts have to use the same first operand.  */
2218
  if (TREE_CODE (def_arg1[0]) != SSA_NAME || def_arg1[0] != def_arg1[1])
2219
    return false;
2220
  if (!TYPE_UNSIGNED (TREE_TYPE (def_arg1[0])))
2221
    return false;
2222
2223
  /* CNT1 + CNT2 == B case above.  */
2224
  if (host_integerp (def_arg2[0], 1)
2225
      && host_integerp (def_arg2[1], 1)
2226
      && (unsigned HOST_WIDE_INT) tree_low_cst (def_arg2[0], 1)
2227
	 + tree_low_cst (def_arg2[1], 1) == TYPE_PRECISION (rtype))
2228
    rotcnt = def_arg2[0];
2229
  else if (TREE_CODE (def_arg2[0]) != SSA_NAME
2230
	   || TREE_CODE (def_arg2[1]) != SSA_NAME)
2231
    return false;
2232
  else
2233
    {
2234
      tree cdef_arg1[2], cdef_arg2[2], def_arg2_alt[2];
2235
      enum tree_code cdef_code[2];
2236
      /* Look through conversion of the shift count argument.
2237
	 The C/C++ FE cast any shift count argument to integer_type_node.
2238
	 The only problem might be if the shift count type maximum value
2239
	 is equal or smaller than number of bits in rtype.  */
2240
      for (i = 0; i < 2; i++)
2241
	{
2242
	  def_arg2_alt[i] = def_arg2[i];
2243
	  defcodefor_name (def_arg2[i], &cdef_code[i],
2244
			   &cdef_arg1[i], &cdef_arg2[i]);
2245
	  if (CONVERT_EXPR_CODE_P (cdef_code[i])
2246
	      && INTEGRAL_TYPE_P (TREE_TYPE (cdef_arg1[i]))
2247
	      && TYPE_PRECISION (TREE_TYPE (cdef_arg1[i]))
2248
		 > floor_log2 (TYPE_PRECISION (rtype))
2249
	      && TYPE_PRECISION (TREE_TYPE (cdef_arg1[i]))
2250
		 == GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (cdef_arg1[i]))))
2251
	    {
2252
	      def_arg2_alt[i] = cdef_arg1[i];
2253
	      defcodefor_name (def_arg2_alt[i], &cdef_code[i],
2254
			       &cdef_arg1[i], &cdef_arg2[i]);
2255
	    }
2256
	}
2257
      for (i = 0; i < 2; i++)
2258
	/* Check for one shift count being Y and the other B - Y,
2259
	   with optional casts.  */
2260
	if (cdef_code[i] == MINUS_EXPR
2261
	    && host_integerp (cdef_arg1[i], 0)
2262
	    && tree_low_cst (cdef_arg1[i], 0) == TYPE_PRECISION (rtype)
2263
	    && TREE_CODE (cdef_arg2[i]) == SSA_NAME)
2264
	  {
2265
	    tree tem;
2266
	    enum tree_code code;
2267
2268
	    if (cdef_arg2[i] == def_arg2[1 - i]
2269
		|| cdef_arg2[i] == def_arg2_alt[1 - i])
2270
	      {
2271
		rotcnt = cdef_arg2[i];
2272
		break;
2273
	      }
2274
	    defcodefor_name (cdef_arg2[i], &code, &tem, NULL);
2275
	    if (CONVERT_EXPR_CODE_P (code)
2276
		&& INTEGRAL_TYPE_P (TREE_TYPE (tem))
2277
		&& TYPE_PRECISION (TREE_TYPE (tem))
2278
		 > floor_log2 (TYPE_PRECISION (rtype))
2279
		&& TYPE_PRECISION (TREE_TYPE (tem))
2280
		 == GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (tem)))
2281
		&& (tem == def_arg2[1 - i]
2282
		    || tem == def_arg2_alt[1 - i]))
2283
	      {
2284
		rotcnt = tem;
2285
		break;
2286
	      }
2287
	  }
2288
	/* The above sequence isn't safe for Y being 0,
2289
	   because then one of the shifts triggers undefined behavior.
2290
	   This alternative is safe even for rotation count of 0.
2291
	   One shift count is Y and the other (-Y) & (B - 1).  */
2292
	else if (cdef_code[i] == BIT_AND_EXPR
2293
		 && host_integerp (cdef_arg2[i], 0)
2294
		 && tree_low_cst (cdef_arg2[i], 0)
2295
		    == TYPE_PRECISION (rtype) - 1
2296
		 && TREE_CODE (cdef_arg1[i]) == SSA_NAME)
2297
	  {
2298
	    tree tem;
2299
	    enum tree_code code;
2300
2301
	    defcodefor_name (cdef_arg1[i], &code, &tem, NULL);
2302
	    if (CONVERT_EXPR_CODE_P (code)
2303
		&& INTEGRAL_TYPE_P (TREE_TYPE (tem))
2304
		&& TYPE_PRECISION (TREE_TYPE (tem))
2305
		 > floor_log2 (TYPE_PRECISION (rtype))
2306
		&& TYPE_PRECISION (TREE_TYPE (tem))
2307
		 == GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (tem))))
2308
	      defcodefor_name (tem, &code, &tem, NULL);
2309
2310
	    if (code == NEGATE_EXPR)
2311
	      {
2312
		if (tem == def_arg2[1 - i] || tem == def_arg2_alt[1 - i])
2313
		  {
2314
		    rotcnt = tem;
2315
		    break;
2316
		  }
2317
		defcodefor_name (tem, &code, &tem, NULL);
2318
		if (CONVERT_EXPR_CODE_P (code)
2319
		    && INTEGRAL_TYPE_P (TREE_TYPE (tem))
2320
		    && TYPE_PRECISION (TREE_TYPE (tem))
2321
		       > floor_log2 (TYPE_PRECISION (rtype))
2322
		    && TYPE_PRECISION (TREE_TYPE (tem))
2323
		       == GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (tem)))
2324
		    && (tem == def_arg2[1 - i]
2325
			|| tem == def_arg2_alt[1 - i]))
2326
		  {
2327
		    rotcnt = tem;
2328
		    break;
2329
		  }
2330
	      }
2331
	  }
2332
      if (rotcnt == NULL_TREE)
2333
	return false;
2334
      swapped_p = i != 1;
2335
    }
2336
2337
  if (!useless_type_conversion_p (TREE_TYPE (def_arg2[0]),
2338
				  TREE_TYPE (rotcnt)))
2339
    {
2340
      g = gimple_build_assign_with_ops (NOP_EXPR,
2341
					make_ssa_name (TREE_TYPE (def_arg2[0]),
2342
						       NULL),
2343
					rotcnt, NULL_TREE);
2344
      gsi_insert_before (gsi, g, GSI_SAME_STMT);
2345
      rotcnt = gimple_assign_lhs (g);
2346
    }
2347
  lhs = gimple_assign_lhs (stmt);
2348
  if (!useless_type_conversion_p (rtype, TREE_TYPE (def_arg1[0])))
2349
    lhs = make_ssa_name (TREE_TYPE (def_arg1[0]), NULL);
2350
  g = gimple_build_assign_with_ops (((def_code[0] == LSHIFT_EXPR) ^ swapped_p)
2351
				    ? LROTATE_EXPR : RROTATE_EXPR,
2352
				    lhs, def_arg1[0], rotcnt);
2353
  if (!useless_type_conversion_p (rtype, TREE_TYPE (def_arg1[0])))
2354
    {
2355
      gsi_insert_before (gsi, g, GSI_SAME_STMT);
2356
      g = gimple_build_assign_with_ops (NOP_EXPR, gimple_assign_lhs (stmt),
2357
					lhs, NULL_TREE);
2358
    }
2359
  gsi_replace (gsi, g, false);
2360
  return true;
2361
}
2362
2127
/* Perform re-associations of the plus or minus statement STMT that are
2363
/* Perform re-associations of the plus or minus statement STMT that are
2128
   always permitted.  Returns true if the CFG was changed.  */
2364
   always permitted.  Returns true if the CFG was changed.  */
2129
2365
Lines 3114-3119 ssa_forward_propagate_and_combine (void) Link Here
3114
		      cfg_changed = true;
3350
		      cfg_changed = true;
3115
		    changed = did_something != 0;
3351
		    changed = did_something != 0;
3116
		  }
3352
		  }
3353
		else if ((code == PLUS_EXPR
3354
			  || code == BIT_IOR_EXPR
3355
			  || code == BIT_XOR_EXPR)
3356
			 && simplify_rotate (&gsi))
3357
		  changed = true;
3117
		else if (code == BIT_AND_EXPR
3358
		else if (code == BIT_AND_EXPR
3118
			 || code == BIT_IOR_EXPR
3359
			 || code == BIT_IOR_EXPR
3119
			 || code == BIT_XOR_EXPR)
3360
			 || code == BIT_XOR_EXPR)
(-)gcc/testsuite/c-c++-common/rotate-1.c.jj (+389 lines)
Line 0 Link Here
1
/* Check rotate pattern detection.  */
2
/* { dg-do compile } */
3
/* { dg-options "-O2 -fdump-tree-optimized" } */
4
/* { dg-final { scan-tree-dump-times "r\[<>]\[<>]" 64 "optimized" } } */
5
/* { dg-final { cleanup-tree-dump "optimized" } } */
6
7
unsigned int
8
f1 (unsigned int x, unsigned int y)
9
{
10
  return (x << y) | (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - y));
11
}
12
13
unsigned int
14
f2 (unsigned int x, unsigned long int y)
15
{
16
  return (x << y) | (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - y));
17
}
18
19
unsigned int
20
f3 (unsigned int x, int y __attribute__((unused)))
21
{
22
  return (x << 1) | (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - 1));
23
}
24
25
unsigned int
26
f4 (unsigned int x, int y __attribute__((unused)))
27
{
28
  return (x << (__CHAR_BIT__ * __SIZEOF_INT__ - 1)) | (x >> 1);
29
}
30
31
unsigned short int
32
f5 (unsigned short int x, unsigned int y)
33
{
34
  return (x << y) | (x >> (__CHAR_BIT__ * __SIZEOF_SHORT__ - y));
35
}
36
37
unsigned short int
38
f6 (unsigned short int x, unsigned long int y)
39
{
40
  return (x << y) | (x >> (__CHAR_BIT__ * __SIZEOF_SHORT__ - y));
41
}
42
43
unsigned char
44
f7 (unsigned char x, unsigned int y)
45
{
46
  return (x << y) | (x >> (__CHAR_BIT__ - y));
47
}
48
49
unsigned char
50
f8 (unsigned char x, unsigned long int y)
51
{
52
  return (x << y) | (x >> (__CHAR_BIT__ - y));
53
}
54
55
unsigned int
56
f9 (unsigned int x, unsigned int y)
57
{
58
  return (x << y) | (x >> (__CHAR_BIT__ * sizeof (unsigned int) - y));
59
}
60
61
unsigned int
62
f10 (unsigned int x, unsigned long int y)
63
{
64
  return (x << y) | (x >> (__CHAR_BIT__ * sizeof (unsigned int) - y));
65
}
66
67
unsigned int
68
f11 (unsigned int x, int y __attribute__((unused)))
69
{
70
  return (x << 1) | (x >> (__CHAR_BIT__ * sizeof (unsigned int) - 1));
71
}
72
73
unsigned int
74
f12 (unsigned int x, int y __attribute__((unused)))
75
{
76
  return (x << (__CHAR_BIT__ * sizeof (unsigned int) - 1)) | (x >> 1);
77
}
78
79
unsigned short int
80
f13 (unsigned short int x, unsigned int y)
81
{
82
  return (x << y) | (x >> (__CHAR_BIT__ * sizeof (unsigned short) - y));
83
}
84
85
unsigned short int
86
f14 (unsigned short int x, unsigned long int y)
87
{
88
  return (x << y) | (x >> (__CHAR_BIT__ * sizeof (unsigned short) - y));
89
}
90
91
unsigned char
92
f15 (unsigned char x, unsigned int y)
93
{
94
  return (x << y) | (x >> (__CHAR_BIT__ * sizeof (unsigned char) - y));
95
}
96
97
unsigned char
98
f16 (unsigned char x, unsigned long int y)
99
{
100
  return (x << y) | (x >> (__CHAR_BIT__ * sizeof (unsigned char) - y));
101
}
102
103
unsigned int
104
f17 (unsigned int x, unsigned int y)
105
{
106
  return (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - y)) ^ (x << y);
107
}
108
109
unsigned int
110
f18 (unsigned int x, unsigned long int y)
111
{
112
  return (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - y)) ^ (x << y);
113
}
114
115
unsigned int
116
f19 (unsigned int x, int y __attribute__((unused)))
117
{
118
  return (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - 1)) ^ (x << 1);
119
}
120
121
unsigned int
122
f20 (unsigned int x, int y __attribute__((unused)))
123
{
124
  return (x >> 1) ^ (x << (__CHAR_BIT__ * __SIZEOF_INT__ - 1));
125
}
126
127
unsigned short int
128
f21 (unsigned short int x, unsigned int y)
129
{
130
  return (x >> (__CHAR_BIT__ * __SIZEOF_SHORT__ - y)) ^ (x << y);
131
}
132
133
unsigned short int
134
f22 (unsigned short int x, unsigned long int y)
135
{
136
  return (x >> (__CHAR_BIT__ * __SIZEOF_SHORT__ - y)) ^ (x << y);
137
}
138
139
unsigned char
140
f23 (unsigned char x, unsigned int y)
141
{
142
  return (x >> (__CHAR_BIT__ - y)) ^ (x << y);
143
}
144
145
unsigned char
146
f24 (unsigned char x, unsigned long int y)
147
{
148
  return (x >> (__CHAR_BIT__ - y)) ^ (x << y);
149
}
150
151
unsigned int
152
f25 (unsigned int x, unsigned int y)
153
{
154
  return (x >> (__CHAR_BIT__ * sizeof (unsigned int) - y)) ^ (x << y);
155
}
156
157
unsigned int
158
f26 (unsigned int x, unsigned long int y)
159
{
160
  return (x >> (__CHAR_BIT__ * sizeof (unsigned int) - y)) ^ (x << y);
161
}
162
163
unsigned int
164
f27 (unsigned int x, int y __attribute__((unused)))
165
{
166
  return (x >> (__CHAR_BIT__ * sizeof (unsigned int) - 1)) ^ (x << 1);
167
}
168
169
unsigned int
170
f28 (unsigned int x, int y __attribute__((unused)))
171
{
172
  return (x >> 1) ^ (x << (__CHAR_BIT__ * sizeof (unsigned int) - 1));
173
}
174
175
unsigned short int
176
f29 (unsigned short int x, unsigned int y)
177
{
178
  return (x >> (__CHAR_BIT__ * sizeof (unsigned short) - y)) ^ (x << y);
179
}
180
181
unsigned short int
182
f30 (unsigned short int x, unsigned long int y)
183
{
184
  return (x >> (__CHAR_BIT__ * sizeof (unsigned short) - y)) ^ (x << y);
185
}
186
187
unsigned char
188
f31 (unsigned char x, unsigned int y)
189
{
190
  return (x >> (__CHAR_BIT__ * sizeof (unsigned char) - y)) ^ (x << y);
191
}
192
193
unsigned char
194
f32 (unsigned char x, unsigned long int y)
195
{
196
  return (x >> (__CHAR_BIT__ * sizeof (unsigned char) - y)) ^ (x << y);
197
}
198
199
unsigned int
200
f33 (unsigned int x, unsigned int y)
201
{
202
  return (x >> y) | (x << (__CHAR_BIT__ * __SIZEOF_INT__ - y));
203
}
204
205
unsigned int
206
f34 (unsigned int x, unsigned long int y)
207
{
208
  return (x >> y) | (x << (__CHAR_BIT__ * __SIZEOF_INT__ - y));
209
}
210
211
unsigned int
212
f35 (unsigned int x, int y __attribute__((unused)))
213
{
214
  return (x >> 1) | (x << (__CHAR_BIT__ * __SIZEOF_INT__ - 1));
215
}
216
217
unsigned int
218
f36 (unsigned int x, int y __attribute__((unused)))
219
{
220
  return (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - 1)) | (x << 1);
221
}
222
223
unsigned short int
224
f37 (unsigned short int x, unsigned int y)
225
{
226
  return (x >> y) | (x << (__CHAR_BIT__ * __SIZEOF_SHORT__ - y));
227
}
228
229
unsigned short int
230
f38 (unsigned short int x, unsigned long int y)
231
{
232
  return (x >> y) | (x << (__CHAR_BIT__ * __SIZEOF_SHORT__ - y));
233
}
234
235
unsigned char
236
f39 (unsigned char x, unsigned int y)
237
{
238
  return (x >> y) | (x << (__CHAR_BIT__ - y));
239
}
240
241
unsigned char
242
f40 (unsigned char x, unsigned long int y)
243
{
244
  return (x >> y) | (x << (__CHAR_BIT__ - y));
245
}
246
247
unsigned int
248
f41 (unsigned int x, unsigned int y)
249
{
250
  return (x >> y) | (x << (__CHAR_BIT__ * sizeof (unsigned int) - y));
251
}
252
253
unsigned int
254
f42 (unsigned int x, unsigned long int y)
255
{
256
  return (x >> y) | (x << (__CHAR_BIT__ * sizeof (unsigned int) - y));
257
}
258
259
unsigned int
260
f43 (unsigned int x, int y __attribute__((unused)))
261
{
262
  return (x >> 1) | (x << (__CHAR_BIT__ * sizeof (unsigned int) - 1));
263
}
264
265
unsigned int
266
f44 (unsigned int x, int y __attribute__((unused)))
267
{
268
  return (x >> (__CHAR_BIT__ * sizeof (unsigned int) - 1)) | (x << 1);
269
}
270
271
unsigned short int
272
f45 (unsigned short int x, unsigned int y)
273
{
274
  return (x >> y) | (x << (__CHAR_BIT__ * sizeof (unsigned short) - y));
275
}
276
277
unsigned short int
278
f46 (unsigned short int x, unsigned long int y)
279
{
280
  return (x >> y) | (x << (__CHAR_BIT__ * sizeof (unsigned short) - y));
281
}
282
283
unsigned char
284
f47 (unsigned char x, unsigned int y)
285
{
286
  return (x >> y) | (x << (__CHAR_BIT__ * sizeof (unsigned char) - y));
287
}
288
289
unsigned char
290
f48 (unsigned char x, unsigned long int y)
291
{
292
  return (x >> y) | (x << (__CHAR_BIT__ * sizeof (unsigned char) - y));
293
}
294
295
unsigned int
296
f49 (unsigned int x, unsigned int y)
297
{
298
  return (x << (__CHAR_BIT__ * __SIZEOF_INT__ - y)) ^ (x >> y);
299
}
300
301
unsigned int
302
f50 (unsigned int x, unsigned long int y)
303
{
304
  return (x << (__CHAR_BIT__ * __SIZEOF_INT__ - y)) ^ (x >> y);
305
}
306
307
unsigned int
308
f51 (unsigned int x, int y __attribute__((unused)))
309
{
310
  return (x << (__CHAR_BIT__ * __SIZEOF_INT__ - 1)) ^ (x >> 1);
311
}
312
313
unsigned int
314
f52 (unsigned int x, int y __attribute__((unused)))
315
{
316
  return (x << 1) ^ (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - 1));
317
}
318
319
unsigned short int
320
f53 (unsigned short int x, unsigned int y)
321
{
322
  return (x << (__CHAR_BIT__ * __SIZEOF_SHORT__ - y)) ^ (x >> y);
323
}
324
325
unsigned short int
326
f54 (unsigned short int x, unsigned long int y)
327
{
328
  return (x << (__CHAR_BIT__ * __SIZEOF_SHORT__ - y)) ^ (x >> y);
329
}
330
331
unsigned char
332
f55 (unsigned char x, unsigned int y)
333
{
334
  return (x << (__CHAR_BIT__ - y)) ^ (x >> y);
335
}
336
337
unsigned char
338
f56 (unsigned char x, unsigned long int y)
339
{
340
  return (x << (__CHAR_BIT__ - y)) ^ (x >> y);
341
}
342
343
unsigned int
344
f57 (unsigned int x, unsigned int y)
345
{
346
  return (x << (__CHAR_BIT__ * sizeof (unsigned int) - y)) ^ (x >> y);
347
}
348
349
unsigned int
350
f58 (unsigned int x, unsigned long int y)
351
{
352
  return (x << (__CHAR_BIT__ * sizeof (unsigned int) - y)) ^ (x >> y);
353
}
354
355
unsigned int
356
f59 (unsigned int x, int y __attribute__((unused)))
357
{
358
  return (x << (__CHAR_BIT__ * sizeof (unsigned int) - 1)) ^ (x >> 1);
359
}
360
361
unsigned int
362
f60 (unsigned int x, int y __attribute__((unused)))
363
{
364
  return (x << 1) ^ (x >> (__CHAR_BIT__ * sizeof (unsigned int) - 1));
365
}
366
367
unsigned short int
368
f61 (unsigned short int x, unsigned int y)
369
{
370
  return (x << (__CHAR_BIT__ * sizeof (unsigned short) - y)) ^ (x >> y);
371
}
372
373
unsigned short int
374
f62 (unsigned short int x, unsigned long int y)
375
{
376
  return (x << (__CHAR_BIT__ * sizeof (unsigned short) - y)) ^ (x >> y);
377
}
378
379
unsigned char
380
f63 (unsigned char x, unsigned int y)
381
{
382
  return (x << (__CHAR_BIT__ * sizeof (unsigned char) - y)) ^ (x >> y);
383
}
384
385
unsigned char
386
f64 (unsigned char x, unsigned long int y)
387
{
388
  return (x << (__CHAR_BIT__ * sizeof (unsigned char) - y)) ^ (x >> y);
389
}
(-)gcc/testsuite/c-c++-common/rotate-1a.c.jj (+44 lines)
Line 0 Link Here
1
/* { dg-do run } */
2
/* { dg-options "-O2 -Wno-overflow" } */
3
4
extern
5
#ifdef __cplusplus
6
"C"
7
#endif
8
void abort (void);
9
10
#ifndef ROTATE_N
11
#define ROTATE_N "rotate-1.c"
12
#endif
13
14
#include ROTATE_N
15
16
unsigned int expected[] = {
17
0x91a2b3c0, 0x91a2b3c0, 0x2468acf0, 0x91a2b3c, 0xb3c2, 0xb3c2, 0xc3, 0xc3,
18
0x91a2b3c0, 0x91a2b3c0, 0x2468acf0, 0x91a2b3c, 0xb3c2, 0xb3c2, 0xc3, 0xc3,
19
0x91a2b3c0, 0x91a2b3c0, 0x2468acf0, 0x91a2b3c, 0xb3c2, 0xb3c2, 0xc3, 0xc3,
20
0x91a2b3c0, 0x91a2b3c0, 0x2468acf0, 0x91a2b3c, 0xb3c2, 0xb3c2, 0xc3, 0xc3,
21
0x2468acf, 0x2468acf, 0x91a2b3c, 0x2468acf0, 0xacf, 0xacf, 0xf, 0xf,
22
0x2468acf, 0x2468acf, 0x91a2b3c, 0x2468acf0, 0xacf, 0xacf, 0xf, 0xf,
23
0x2468acf, 0x2468acf, 0x91a2b3c, 0x2468acf0, 0xacf, 0xacf, 0xf, 0xf,
24
0x2468acf, 0x2468acf, 0x91a2b3c, 0x2468acf0, 0xacf, 0xacf, 0xf, 0xf };
25
26
#define F(n) __typeof (f##n) f##n __attribute__((noinline, noclone));
27
#define D(n) F(n##0) F(n##1) F(n##2) F(n##3) F(n##4) F(n##5) F(n##6) F(n##7) F(n##8) F(n##9)
28
#define ALL \
29
F(1) F(2) F(3) F(4) F(5) F(6) F(7) F(8) F(9) \
30
D(1) D(2) D(3) D(4) D(5) F(60) F(61) F(62) F(63) F(64)
31
ALL
32
33
int
34
main ()
35
{
36
#if __CHAR_BIT__ != 8 || __SIZEOF_SHORT__ != 2 || __SIZEOF_INT__ != 4
37
  return 0;
38
#else
39
#undef F
40
#define F(n) if ((unsigned int) f##n (0x12345678U, 3) != expected[n - 1]) abort ();
41
  ALL
42
  return 0;
43
#endif
44
}
(-)gcc/testsuite/c-c++-common/rotate-2.c.jj (+389 lines)
Line 0 Link Here
1
/* Check rotate pattern detection.  */
2
/* { dg-do compile } */
3
/* { dg-options "-O2 -fdump-tree-optimized" } */
4
/* { dg-final { scan-tree-dump-times "r\[<>]\[<>]" 64 "optimized" } } */
5
/* { dg-final { cleanup-tree-dump "optimized" } } */
6
7
unsigned int
8
f1 (unsigned int x, unsigned int y)
9
{
10
  return (x << y) | (x >> ((-y) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
11
}
12
13
unsigned int
14
f2 (unsigned int x, unsigned long int y)
15
{
16
  return (x << y) | (x >> ((-y) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
17
}
18
19
unsigned int
20
f3 (unsigned int x, int y __attribute__((unused)))
21
{
22
  return (x << 1) | (x >> ((-1) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
23
}
24
25
unsigned int
26
f4 (unsigned int x, int y __attribute__((unused)))
27
{
28
  return (x << ((-1) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) | (x >> 1);
29
}
30
31
unsigned short int
32
f5 (unsigned short int x, unsigned int y)
33
{
34
  return (x << y) | (x >> ((-y) & (__CHAR_BIT__ * __SIZEOF_SHORT__ - 1)));
35
}
36
37
unsigned short int
38
f6 (unsigned short int x, unsigned long int y)
39
{
40
  return (x << y) | (x >> ((-y) & (__CHAR_BIT__ * __SIZEOF_SHORT__ - 1)));
41
}
42
43
unsigned char
44
f7 (unsigned char x, unsigned int y)
45
{
46
  return (x << y) | (x >> ((-y) & (__CHAR_BIT__ - 1)));
47
}
48
49
unsigned char
50
f8 (unsigned char x, unsigned long int y)
51
{
52
  return (x << y) | (x >> ((-y) & (__CHAR_BIT__ - 1)));
53
}
54
55
unsigned int
56
f9 (unsigned int x, unsigned int y)
57
{
58
  return (x << y) | (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned int) - 1)));
59
}
60
61
unsigned int
62
f10 (unsigned int x, unsigned long int y)
63
{
64
  return (x << y) | (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned int) - 1)));
65
}
66
67
unsigned int
68
f11 (unsigned int x, int y __attribute__((unused)))
69
{
70
  return (x << 1) | (x >> ((-1) & (__CHAR_BIT__ * sizeof (unsigned int) - 1)));
71
}
72
73
unsigned int
74
f12 (unsigned int x, int y __attribute__((unused)))
75
{
76
  return (x << ((-1) & (__CHAR_BIT__ * sizeof (unsigned int) - 1))) | (x >> 1);
77
}
78
79
unsigned short int
80
f13 (unsigned short int x, unsigned int y)
81
{
82
  return (x << y) | (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned short) - 1)));
83
}
84
85
unsigned short int
86
f14 (unsigned short int x, unsigned long int y)
87
{
88
  return (x << y) | (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned short) - 1)));
89
}
90
91
unsigned char
92
f15 (unsigned char x, unsigned int y)
93
{
94
  return (x << y) | (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned char) - 1)));
95
}
96
97
unsigned char
98
f16 (unsigned char x, unsigned long int y)
99
{
100
  return (x << y) | (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned char) - 1)));
101
}
102
103
unsigned int
104
f17 (unsigned int x, unsigned int y)
105
{
106
  return (x >> ((-y) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) ^ (x << y);
107
}
108
109
unsigned int
110
f18 (unsigned int x, unsigned long int y)
111
{
112
  return (x >> ((-y) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) ^ (x << y);
113
}
114
115
unsigned int
116
f19 (unsigned int x, int y __attribute__((unused)))
117
{
118
  return (x >> ((-1) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) ^ (x << 1);
119
}
120
121
unsigned int
122
f20 (unsigned int x, int y __attribute__((unused)))
123
{
124
  return (x >> 1) ^ (x << ((-1) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
125
}
126
127
unsigned short int
128
f21 (unsigned short int x, unsigned int y)
129
{
130
  return (x >> ((-y) & (__CHAR_BIT__ * __SIZEOF_SHORT__ - 1))) ^ (x << y);
131
}
132
133
unsigned short int
134
f22 (unsigned short int x, unsigned long int y)
135
{
136
  return (x >> ((-y) & (__CHAR_BIT__ * __SIZEOF_SHORT__ - 1))) ^ (x << y);
137
}
138
139
unsigned char
140
f23 (unsigned char x, unsigned int y)
141
{
142
  return (x >> ((-y) & (__CHAR_BIT__ - 1))) ^ (x << y);
143
}
144
145
unsigned char
146
f24 (unsigned char x, unsigned long int y)
147
{
148
  return (x >> ((-y) & (__CHAR_BIT__ - 1))) ^ (x << y);
149
}
150
151
unsigned int
152
f25 (unsigned int x, unsigned int y)
153
{
154
  return (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned int) - 1))) ^ (x << y);
155
}
156
157
unsigned int
158
f26 (unsigned int x, unsigned long int y)
159
{
160
  return (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned int) - 1))) ^ (x << y);
161
}
162
163
unsigned int
164
f27 (unsigned int x, int y __attribute__((unused)))
165
{
166
  return (x >> ((-1) & (__CHAR_BIT__ * sizeof (unsigned int) - 1))) ^ (x << 1);
167
}
168
169
unsigned int
170
f28 (unsigned int x, int y __attribute__((unused)))
171
{
172
  return (x >> 1) ^ (x << ((-1) & (__CHAR_BIT__ * sizeof (unsigned int) - 1)));
173
}
174
175
unsigned short int
176
f29 (unsigned short int x, unsigned int y)
177
{
178
  return (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned short) - 1))) ^ (x << y);
179
}
180
181
unsigned short int
182
f30 (unsigned short int x, unsigned long int y)
183
{
184
  return (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned short) - 1))) ^ (x << y);
185
}
186
187
unsigned char
188
f31 (unsigned char x, unsigned int y)
189
{
190
  return (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned char) - 1))) ^ (x << y);
191
}
192
193
unsigned char
194
f32 (unsigned char x, unsigned long int y)
195
{
196
  return (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned char) - 1))) ^ (x << y);
197
}
198
199
unsigned int
200
f33 (unsigned int x, unsigned int y)
201
{
202
  return (x >> y) | (x << ((-y) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
203
}
204
205
unsigned int
206
f34 (unsigned int x, unsigned long int y)
207
{
208
  return (x >> y) | (x << ((-y) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
209
}
210
211
unsigned int
212
f35 (unsigned int x, int y __attribute__((unused)))
213
{
214
  return (x >> 1) | (x << ((-1) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
215
}
216
217
unsigned int
218
f36 (unsigned int x, int y __attribute__((unused)))
219
{
220
  return (x >> ((-1) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) | (x << 1);
221
}
222
223
unsigned short int
224
f37 (unsigned short int x, unsigned int y)
225
{
226
  return (x >> y) | (x << ((-y) & (__CHAR_BIT__ * __SIZEOF_SHORT__ - 1)));
227
}
228
229
unsigned short int
230
f38 (unsigned short int x, unsigned long int y)
231
{
232
  return (x >> y) | (x << ((-y) & (__CHAR_BIT__ * __SIZEOF_SHORT__ - 1)));
233
}
234
235
unsigned char
236
f39 (unsigned char x, unsigned int y)
237
{
238
  return (x >> y) | (x << ((-y) & (__CHAR_BIT__ - 1)));
239
}
240
241
unsigned char
242
f40 (unsigned char x, unsigned long int y)
243
{
244
  return (x >> y) | (x << ((-y) & (__CHAR_BIT__ - 1)));
245
}
246
247
unsigned int
248
f41 (unsigned int x, unsigned int y)
249
{
250
  return (x >> y) | (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned int) - 1)));
251
}
252
253
unsigned int
254
f42 (unsigned int x, unsigned long int y)
255
{
256
  return (x >> y) | (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned int) - 1)));
257
}
258
259
unsigned int
260
f43 (unsigned int x, int y __attribute__((unused)))
261
{
262
  return (x >> 1) | (x << ((-1) & (__CHAR_BIT__ * sizeof (unsigned int) - 1)));
263
}
264
265
unsigned int
266
f44 (unsigned int x, int y __attribute__((unused)))
267
{
268
  return (x >> ((-1) & (__CHAR_BIT__ * sizeof (unsigned int) - 1))) | (x << 1);
269
}
270
271
unsigned short int
272
f45 (unsigned short int x, unsigned int y)
273
{
274
  return (x >> y) | (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned short) - 1)));
275
}
276
277
unsigned short int
278
f46 (unsigned short int x, unsigned long int y)
279
{
280
  return (x >> y) | (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned short) - 1)));
281
}
282
283
unsigned char
284
f47 (unsigned char x, unsigned int y)
285
{
286
  return (x >> y) | (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned char) - 1)));
287
}
288
289
unsigned char
290
f48 (unsigned char x, unsigned long int y)
291
{
292
  return (x >> y) | (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned char) - 1)));
293
}
294
295
unsigned int
296
f49 (unsigned int x, unsigned int y)
297
{
298
  return (x << ((-y) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) ^ (x >> y);
299
}
300
301
unsigned int
302
f50 (unsigned int x, unsigned long int y)
303
{
304
  return (x << ((-y) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) ^ (x >> y);
305
}
306
307
unsigned int
308
f51 (unsigned int x, int y __attribute__((unused)))
309
{
310
  return (x << ((-1) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) ^ (x >> 1);
311
}
312
313
unsigned int
314
f52 (unsigned int x, int y __attribute__((unused)))
315
{
316
  return (x << 1) ^ (x >> ((-1) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
317
}
318
319
unsigned short int
320
f53 (unsigned short int x, unsigned int y)
321
{
322
  return (x << ((-y) & (__CHAR_BIT__ * __SIZEOF_SHORT__ - 1))) ^ (x >> y);
323
}
324
325
unsigned short int
326
f54 (unsigned short int x, unsigned long int y)
327
{
328
  return (x << ((-y) & (__CHAR_BIT__ * __SIZEOF_SHORT__ - 1))) ^ (x >> y);
329
}
330
331
unsigned char
332
f55 (unsigned char x, unsigned int y)
333
{
334
  return (x << ((-y) & (__CHAR_BIT__ - 1))) ^ (x >> y);
335
}
336
337
unsigned char
338
f56 (unsigned char x, unsigned long int y)
339
{
340
  return (x << ((-y) & (__CHAR_BIT__ - 1))) ^ (x >> y);
341
}
342
343
unsigned int
344
f57 (unsigned int x, unsigned int y)
345
{
346
  return (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned int) - 1))) ^ (x >> y);
347
}
348
349
unsigned int
350
f58 (unsigned int x, unsigned long int y)
351
{
352
  return (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned int) - 1))) ^ (x >> y);
353
}
354
355
unsigned int
356
f59 (unsigned int x, int y __attribute__((unused)))
357
{
358
  return (x << ((-1) & (__CHAR_BIT__ * sizeof (unsigned int) - 1))) ^ (x >> 1);
359
}
360
361
unsigned int
362
f60 (unsigned int x, int y __attribute__((unused)))
363
{
364
  return (x << 1) ^ (x >> ((-1) & (__CHAR_BIT__ * sizeof (unsigned int) - 1)));
365
}
366
367
unsigned short int
368
f61 (unsigned short int x, unsigned int y)
369
{
370
  return (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned short) - 1))) ^ (x >> y);
371
}
372
373
unsigned short int
374
f62 (unsigned short int x, unsigned long int y)
375
{
376
  return (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned short) - 1))) ^ (x >> y);
377
}
378
379
unsigned char
380
f63 (unsigned char x, unsigned int y)
381
{
382
  return (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned char) - 1))) ^ (x >> y);
383
}
384
385
unsigned char
386
f64 (unsigned char x, unsigned long int y)
387
{
388
  return (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned char) - 1))) ^ (x >> y);
389
}
(-)gcc/testsuite/c-c++-common/rotate-2a.c.jj (+6 lines)
Line 0 Link Here
1
/* { dg-do run } */
2
/* { dg-options "-O2 -Wno-overflow" } */
3
4
#define ROTATE_N "rotate-2.c"
5
6
#include "rotate-1a.c"
(-)gcc/testsuite/c-c++-common/rotate-3.c.jj (+389 lines)
Line 0 Link Here
1
/* Check rotate pattern detection.  */
2
/* { dg-do compile } */
3
/* { dg-options "-O2 -fdump-tree-optimized" } */
4
/* { dg-final { scan-tree-dump-times "r\[<>]\[<>]" 64 "optimized" } } */
5
/* { dg-final { cleanup-tree-dump "optimized" } } */
6
7
unsigned int
8
f1 (unsigned int x, int y)
9
{
10
  return (x << y) | (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - y));
11
}
12
13
unsigned int
14
f2 (unsigned int x, long int y)
15
{
16
  return (x << y) | (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - y));
17
}
18
19
unsigned int
20
f3 (unsigned int x, int y __attribute__((unused)))
21
{
22
  return (x << 1) | (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - 1));
23
}
24
25
unsigned int
26
f4 (unsigned int x, int y __attribute__((unused)))
27
{
28
  return (x << (__CHAR_BIT__ * __SIZEOF_INT__ - 1)) | (x >> 1);
29
}
30
31
unsigned short int
32
f5 (unsigned short int x, int y)
33
{
34
  return (x << y) | (x >> (__CHAR_BIT__ * __SIZEOF_SHORT__ - y));
35
}
36
37
unsigned short int
38
f6 (unsigned short int x, long int y)
39
{
40
  return (x << y) | (x >> (__CHAR_BIT__ * __SIZEOF_SHORT__ - y));
41
}
42
43
unsigned char
44
f7 (unsigned char x, int y)
45
{
46
  return (x << y) | (x >> (__CHAR_BIT__ - y));
47
}
48
49
unsigned char
50
f8 (unsigned char x, long int y)
51
{
52
  return (x << y) | (x >> (__CHAR_BIT__ - y));
53
}
54
55
unsigned int
56
f9 (unsigned int x, int y)
57
{
58
  return (x << y) | (x >> (__CHAR_BIT__ * sizeof (unsigned int) - y));
59
}
60
61
unsigned int
62
f10 (unsigned int x, long int y)
63
{
64
  return (x << y) | (x >> (__CHAR_BIT__ * sizeof (unsigned int) - y));
65
}
66
67
unsigned int
68
f11 (unsigned int x, int y __attribute__((unused)))
69
{
70
  return (x << 1) | (x >> (__CHAR_BIT__ * sizeof (unsigned int) - 1));
71
}
72
73
unsigned int
74
f12 (unsigned int x, int y __attribute__((unused)))
75
{
76
  return (x << (__CHAR_BIT__ * sizeof (unsigned int) - 1)) | (x >> 1);
77
}
78
79
unsigned short int
80
f13 (unsigned short int x, int y)
81
{
82
  return (x << y) | (x >> (__CHAR_BIT__ * sizeof (unsigned short) - y));
83
}
84
85
unsigned short int
86
f14 (unsigned short int x, long int y)
87
{
88
  return (x << y) | (x >> (__CHAR_BIT__ * sizeof (unsigned short) - y));
89
}
90
91
unsigned char
92
f15 (unsigned char x, int y)
93
{
94
  return (x << y) | (x >> (__CHAR_BIT__ * sizeof (unsigned char) - y));
95
}
96
97
unsigned char
98
f16 (unsigned char x, long int y)
99
{
100
  return (x << y) | (x >> (__CHAR_BIT__ * sizeof (unsigned char) - y));
101
}
102
103
unsigned int
104
f17 (unsigned int x, int y)
105
{
106
  return (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - y)) ^ (x << y);
107
}
108
109
unsigned int
110
f18 (unsigned int x, long int y)
111
{
112
  return (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - y)) ^ (x << y);
113
}
114
115
unsigned int
116
f19 (unsigned int x, int y __attribute__((unused)))
117
{
118
  return (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - 1)) ^ (x << 1);
119
}
120
121
unsigned int
122
f20 (unsigned int x, int y __attribute__((unused)))
123
{
124
  return (x >> 1) ^ (x << (__CHAR_BIT__ * __SIZEOF_INT__ - 1));
125
}
126
127
unsigned short int
128
f21 (unsigned short int x, int y)
129
{
130
  return (x >> (__CHAR_BIT__ * __SIZEOF_SHORT__ - y)) ^ (x << y);
131
}
132
133
unsigned short int
134
f22 (unsigned short int x, long int y)
135
{
136
  return (x >> (__CHAR_BIT__ * __SIZEOF_SHORT__ - y)) ^ (x << y);
137
}
138
139
unsigned char
140
f23 (unsigned char x, int y)
141
{
142
  return (x >> (__CHAR_BIT__ - y)) ^ (x << y);
143
}
144
145
unsigned char
146
f24 (unsigned char x, long int y)
147
{
148
  return (x >> (__CHAR_BIT__ - y)) ^ (x << y);
149
}
150
151
unsigned int
152
f25 (unsigned int x, int y)
153
{
154
  return (x >> (__CHAR_BIT__ * sizeof (unsigned int) - y)) ^ (x << y);
155
}
156
157
unsigned int
158
f26 (unsigned int x, long int y)
159
{
160
  return (x >> (__CHAR_BIT__ * sizeof (unsigned int) - y)) ^ (x << y);
161
}
162
163
unsigned int
164
f27 (unsigned int x, int y __attribute__((unused)))
165
{
166
  return (x >> (__CHAR_BIT__ * sizeof (unsigned int) - 1)) ^ (x << 1);
167
}
168
169
unsigned int
170
f28 (unsigned int x, int y __attribute__((unused)))
171
{
172
  return (x >> 1) ^ (x << (__CHAR_BIT__ * sizeof (unsigned int) - 1));
173
}
174
175
unsigned short int
176
f29 (unsigned short int x, int y)
177
{
178
  return (x >> (__CHAR_BIT__ * sizeof (unsigned short) - y)) ^ (x << y);
179
}
180
181
unsigned short int
182
f30 (unsigned short int x, long int y)
183
{
184
  return (x >> (__CHAR_BIT__ * sizeof (unsigned short) - y)) ^ (x << y);
185
}
186
187
unsigned char
188
f31 (unsigned char x, int y)
189
{
190
  return (x >> (__CHAR_BIT__ * sizeof (unsigned char) - y)) ^ (x << y);
191
}
192
193
unsigned char
194
f32 (unsigned char x, long int y)
195
{
196
  return (x >> (__CHAR_BIT__ * sizeof (unsigned char) - y)) ^ (x << y);
197
}
198
199
unsigned int
200
f33 (unsigned int x, int y)
201
{
202
  return (x >> y) | (x << (__CHAR_BIT__ * __SIZEOF_INT__ - y));
203
}
204
205
unsigned int
206
f34 (unsigned int x, long int y)
207
{
208
  return (x >> y) | (x << (__CHAR_BIT__ * __SIZEOF_INT__ - y));
209
}
210
211
unsigned int
212
f35 (unsigned int x, int y __attribute__((unused)))
213
{
214
  return (x >> 1) | (x << (__CHAR_BIT__ * __SIZEOF_INT__ - 1));
215
}
216
217
unsigned int
218
f36 (unsigned int x, int y __attribute__((unused)))
219
{
220
  return (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - 1)) | (x << 1);
221
}
222
223
unsigned short int
224
f37 (unsigned short int x, int y)
225
{
226
  return (x >> y) | (x << (__CHAR_BIT__ * __SIZEOF_SHORT__ - y));
227
}
228
229
unsigned short int
230
f38 (unsigned short int x, long int y)
231
{
232
  return (x >> y) | (x << (__CHAR_BIT__ * __SIZEOF_SHORT__ - y));
233
}
234
235
unsigned char
236
f39 (unsigned char x, int y)
237
{
238
  return (x >> y) | (x << (__CHAR_BIT__ - y));
239
}
240
241
unsigned char
242
f40 (unsigned char x, long int y)
243
{
244
  return (x >> y) | (x << (__CHAR_BIT__ - y));
245
}
246
247
unsigned int
248
f41 (unsigned int x, int y)
249
{
250
  return (x >> y) | (x << (__CHAR_BIT__ * sizeof (unsigned int) - y));
251
}
252
253
unsigned int
254
f42 (unsigned int x, long int y)
255
{
256
  return (x >> y) | (x << (__CHAR_BIT__ * sizeof (unsigned int) - y));
257
}
258
259
unsigned int
260
f43 (unsigned int x, int y __attribute__((unused)))
261
{
262
  return (x >> 1) | (x << (__CHAR_BIT__ * sizeof (unsigned int) - 1));
263
}
264
265
unsigned int
266
f44 (unsigned int x, int y __attribute__((unused)))
267
{
268
  return (x >> (__CHAR_BIT__ * sizeof (unsigned int) - 1)) | (x << 1);
269
}
270
271
unsigned short int
272
f45 (unsigned short int x, int y)
273
{
274
  return (x >> y) | (x << (__CHAR_BIT__ * sizeof (unsigned short) - y));
275
}
276
277
unsigned short int
278
f46 (unsigned short int x, long int y)
279
{
280
  return (x >> y) | (x << (__CHAR_BIT__ * sizeof (unsigned short) - y));
281
}
282
283
unsigned char
284
f47 (unsigned char x, int y)
285
{
286
  return (x >> y) | (x << (__CHAR_BIT__ * sizeof (unsigned char) - y));
287
}
288
289
unsigned char
290
f48 (unsigned char x, long int y)
291
{
292
  return (x >> y) | (x << (__CHAR_BIT__ * sizeof (unsigned char) - y));
293
}
294
295
unsigned int
296
f49 (unsigned int x, int y)
297
{
298
  return (x << (__CHAR_BIT__ * __SIZEOF_INT__ - y)) ^ (x >> y);
299
}
300
301
unsigned int
302
f50 (unsigned int x, long int y)
303
{
304
  return (x << (__CHAR_BIT__ * __SIZEOF_INT__ - y)) ^ (x >> y);
305
}
306
307
unsigned int
308
f51 (unsigned int x, int y __attribute__((unused)))
309
{
310
  return (x << (__CHAR_BIT__ * __SIZEOF_INT__ - 1)) ^ (x >> 1);
311
}
312
313
unsigned int
314
f52 (unsigned int x, int y __attribute__((unused)))
315
{
316
  return (x << 1) ^ (x >> (__CHAR_BIT__ * __SIZEOF_INT__ - 1));
317
}
318
319
unsigned short int
320
f53 (unsigned short int x, int y)
321
{
322
  return (x << (__CHAR_BIT__ * __SIZEOF_SHORT__ - y)) ^ (x >> y);
323
}
324
325
unsigned short int
326
f54 (unsigned short int x, long int y)
327
{
328
  return (x << (__CHAR_BIT__ * __SIZEOF_SHORT__ - y)) ^ (x >> y);
329
}
330
331
unsigned char
332
f55 (unsigned char x, int y)
333
{
334
  return (x << (__CHAR_BIT__ - y)) ^ (x >> y);
335
}
336
337
unsigned char
338
f56 (unsigned char x, long int y)
339
{
340
  return (x << (__CHAR_BIT__ - y)) ^ (x >> y);
341
}
342
343
unsigned int
344
f57 (unsigned int x, int y)
345
{
346
  return (x << (__CHAR_BIT__ * sizeof (unsigned int) - y)) ^ (x >> y);
347
}
348
349
unsigned int
350
f58 (unsigned int x, long int y)
351
{
352
  return (x << (__CHAR_BIT__ * sizeof (unsigned int) - y)) ^ (x >> y);
353
}
354
355
unsigned int
356
f59 (unsigned int x, int y __attribute__((unused)))
357
{
358
  return (x << (__CHAR_BIT__ * sizeof (unsigned int) - 1)) ^ (x >> 1);
359
}
360
361
unsigned int
362
f60 (unsigned int x, int y __attribute__((unused)))
363
{
364
  return (x << 1) ^ (x >> (__CHAR_BIT__ * sizeof (unsigned int) - 1));
365
}
366
367
unsigned short int
368
f61 (unsigned short int x, int y)
369
{
370
  return (x << (__CHAR_BIT__ * sizeof (unsigned short) - y)) ^ (x >> y);
371
}
372
373
unsigned short int
374
f62 (unsigned short int x, long int y)
375
{
376
  return (x << (__CHAR_BIT__ * sizeof (unsigned short) - y)) ^ (x >> y);
377
}
378
379
unsigned char
380
f63 (unsigned char x, int y)
381
{
382
  return (x << (__CHAR_BIT__ * sizeof (unsigned char) - y)) ^ (x >> y);
383
}
384
385
unsigned char
386
f64 (unsigned char x, long int y)
387
{
388
  return (x << (__CHAR_BIT__ * sizeof (unsigned char) - y)) ^ (x >> y);
389
}
(-)gcc/testsuite/c-c++-common/rotate-3a.c.jj (+6 lines)
Line 0 Link Here
1
/* { dg-do run } */
2
/* { dg-options "-O2 -Wno-overflow" } */
3
4
#define ROTATE_N "rotate-4.c"
5
6
#include "rotate-1a.c"
(-)gcc/testsuite/c-c++-common/rotate-4.c.jj (+389 lines)
Line 0 Link Here
1
/* Check rotate pattern detection.  */
2
/* { dg-do compile } */
3
/* { dg-options "-O2 -fdump-tree-optimized" } */
4
/* { dg-final { scan-tree-dump-times "r\[<>]\[<>]" 64 "optimized" } } */
5
/* { dg-final { cleanup-tree-dump "optimized" } } */
6
7
unsigned int
8
f1 (unsigned int x, int y)
9
{
10
  return (x << y) | (x >> ((-y) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
11
}
12
13
unsigned int
14
f2 (unsigned int x, long int y)
15
{
16
  return (x << y) | (x >> ((-y) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
17
}
18
19
unsigned int
20
f3 (unsigned int x, int y __attribute__((unused)))
21
{
22
  return (x << 1) | (x >> ((-1) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
23
}
24
25
unsigned int
26
f4 (unsigned int x, int y __attribute__((unused)))
27
{
28
  return (x << ((-1) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) | (x >> 1);
29
}
30
31
unsigned short int
32
f5 (unsigned short int x, int y)
33
{
34
  return (x << y) | (x >> ((-y) & (__CHAR_BIT__ * __SIZEOF_SHORT__ - 1)));
35
}
36
37
unsigned short int
38
f6 (unsigned short int x, long int y)
39
{
40
  return (x << y) | (x >> ((-y) & (__CHAR_BIT__ * __SIZEOF_SHORT__ - 1)));
41
}
42
43
unsigned char
44
f7 (unsigned char x, int y)
45
{
46
  return (x << y) | (x >> ((-y) & (__CHAR_BIT__ - 1)));
47
}
48
49
unsigned char
50
f8 (unsigned char x, long int y)
51
{
52
  return (x << y) | (x >> ((-y) & (__CHAR_BIT__ - 1)));
53
}
54
55
unsigned int
56
f9 (unsigned int x, int y)
57
{
58
  return (x << y) | (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned int) - 1)));
59
}
60
61
unsigned int
62
f10 (unsigned int x, long int y)
63
{
64
  return (x << y) | (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned int) - 1)));
65
}
66
67
unsigned int
68
f11 (unsigned int x, int y __attribute__((unused)))
69
{
70
  return (x << 1) | (x >> ((-1) & (__CHAR_BIT__ * sizeof (unsigned int) - 1)));
71
}
72
73
unsigned int
74
f12 (unsigned int x, int y __attribute__((unused)))
75
{
76
  return (x << ((-1) & (__CHAR_BIT__ * sizeof (unsigned int) - 1))) | (x >> 1);
77
}
78
79
unsigned short int
80
f13 (unsigned short int x, int y)
81
{
82
  return (x << y) | (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned short) - 1)));
83
}
84
85
unsigned short int
86
f14 (unsigned short int x, long int y)
87
{
88
  return (x << y) | (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned short) - 1)));
89
}
90
91
unsigned char
92
f15 (unsigned char x, int y)
93
{
94
  return (x << y) | (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned char) - 1)));
95
}
96
97
unsigned char
98
f16 (unsigned char x, long int y)
99
{
100
  return (x << y) | (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned char) - 1)));
101
}
102
103
unsigned int
104
f17 (unsigned int x, int y)
105
{
106
  return (x >> ((-y) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) ^ (x << y);
107
}
108
109
unsigned int
110
f18 (unsigned int x, long int y)
111
{
112
  return (x >> ((-y) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) ^ (x << y);
113
}
114
115
unsigned int
116
f19 (unsigned int x, int y __attribute__((unused)))
117
{
118
  return (x >> ((-1) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) ^ (x << 1);
119
}
120
121
unsigned int
122
f20 (unsigned int x, int y __attribute__((unused)))
123
{
124
  return (x >> 1) ^ (x << ((-1) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
125
}
126
127
unsigned short int
128
f21 (unsigned short int x, int y)
129
{
130
  return (x >> ((-y) & (__CHAR_BIT__ * __SIZEOF_SHORT__ - 1))) ^ (x << y);
131
}
132
133
unsigned short int
134
f22 (unsigned short int x, long int y)
135
{
136
  return (x >> ((-y) & (__CHAR_BIT__ * __SIZEOF_SHORT__ - 1))) ^ (x << y);
137
}
138
139
unsigned char
140
f23 (unsigned char x, int y)
141
{
142
  return (x >> ((-y) & (__CHAR_BIT__ - 1))) ^ (x << y);
143
}
144
145
unsigned char
146
f24 (unsigned char x, long int y)
147
{
148
  return (x >> ((-y) & (__CHAR_BIT__ - 1))) ^ (x << y);
149
}
150
151
unsigned int
152
f25 (unsigned int x, int y)
153
{
154
  return (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned int) - 1))) ^ (x << y);
155
}
156
157
unsigned int
158
f26 (unsigned int x, long int y)
159
{
160
  return (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned int) - 1))) ^ (x << y);
161
}
162
163
unsigned int
164
f27 (unsigned int x, int y __attribute__((unused)))
165
{
166
  return (x >> ((-1) & (__CHAR_BIT__ * sizeof (unsigned int) - 1))) ^ (x << 1);
167
}
168
169
unsigned int
170
f28 (unsigned int x, int y __attribute__((unused)))
171
{
172
  return (x >> 1) ^ (x << ((-1) & (__CHAR_BIT__ * sizeof (unsigned int) - 1)));
173
}
174
175
unsigned short int
176
f29 (unsigned short int x, int y)
177
{
178
  return (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned short) - 1))) ^ (x << y);
179
}
180
181
unsigned short int
182
f30 (unsigned short int x, long int y)
183
{
184
  return (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned short) - 1))) ^ (x << y);
185
}
186
187
unsigned char
188
f31 (unsigned char x, int y)
189
{
190
  return (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned char) - 1))) ^ (x << y);
191
}
192
193
unsigned char
194
f32 (unsigned char x, long int y)
195
{
196
  return (x >> ((-y) & (__CHAR_BIT__ * sizeof (unsigned char) - 1))) ^ (x << y);
197
}
198
199
unsigned int
200
f33 (unsigned int x, int y)
201
{
202
  return (x >> y) | (x << ((-y) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
203
}
204
205
unsigned int
206
f34 (unsigned int x, long int y)
207
{
208
  return (x >> y) | (x << ((-y) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
209
}
210
211
unsigned int
212
f35 (unsigned int x, int y __attribute__((unused)))
213
{
214
  return (x >> 1) | (x << ((-1) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
215
}
216
217
unsigned int
218
f36 (unsigned int x, int y __attribute__((unused)))
219
{
220
  return (x >> ((-1) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) | (x << 1);
221
}
222
223
unsigned short int
224
f37 (unsigned short int x, int y)
225
{
226
  return (x >> y) | (x << ((-y) & (__CHAR_BIT__ * __SIZEOF_SHORT__ - 1)));
227
}
228
229
unsigned short int
230
f38 (unsigned short int x, long int y)
231
{
232
  return (x >> y) | (x << ((-y) & (__CHAR_BIT__ * __SIZEOF_SHORT__ - 1)));
233
}
234
235
unsigned char
236
f39 (unsigned char x, int y)
237
{
238
  return (x >> y) | (x << ((-y) & (__CHAR_BIT__ - 1)));
239
}
240
241
unsigned char
242
f40 (unsigned char x, long int y)
243
{
244
  return (x >> y) | (x << ((-y) & (__CHAR_BIT__ - 1)));
245
}
246
247
unsigned int
248
f41 (unsigned int x, int y)
249
{
250
  return (x >> y) | (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned int) - 1)));
251
}
252
253
unsigned int
254
f42 (unsigned int x, long int y)
255
{
256
  return (x >> y) | (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned int) - 1)));
257
}
258
259
unsigned int
260
f43 (unsigned int x, int y __attribute__((unused)))
261
{
262
  return (x >> 1) | (x << ((-1) & (__CHAR_BIT__ * sizeof (unsigned int) - 1)));
263
}
264
265
unsigned int
266
f44 (unsigned int x, int y __attribute__((unused)))
267
{
268
  return (x >> ((-1) & (__CHAR_BIT__ * sizeof (unsigned int) - 1))) | (x << 1);
269
}
270
271
unsigned short int
272
f45 (unsigned short int x, int y)
273
{
274
  return (x >> y) | (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned short) - 1)));
275
}
276
277
unsigned short int
278
f46 (unsigned short int x, long int y)
279
{
280
  return (x >> y) | (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned short) - 1)));
281
}
282
283
unsigned char
284
f47 (unsigned char x, int y)
285
{
286
  return (x >> y) | (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned char) - 1)));
287
}
288
289
unsigned char
290
f48 (unsigned char x, long int y)
291
{
292
  return (x >> y) | (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned char) - 1)));
293
}
294
295
unsigned int
296
f49 (unsigned int x, int y)
297
{
298
  return (x << ((-y) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) ^ (x >> y);
299
}
300
301
unsigned int
302
f50 (unsigned int x, long int y)
303
{
304
  return (x << ((-y) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) ^ (x >> y);
305
}
306
307
unsigned int
308
f51 (unsigned int x, int y __attribute__((unused)))
309
{
310
  return (x << ((-1) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1))) ^ (x >> 1);
311
}
312
313
unsigned int
314
f52 (unsigned int x, int y __attribute__((unused)))
315
{
316
  return (x << 1) ^ (x >> ((-1) & (__CHAR_BIT__ * __SIZEOF_INT__ - 1)));
317
}
318
319
unsigned short int
320
f53 (unsigned short int x, int y)
321
{
322
  return (x << ((-y) & (__CHAR_BIT__ * __SIZEOF_SHORT__ - 1))) ^ (x >> y);
323
}
324
325
unsigned short int
326
f54 (unsigned short int x, long int y)
327
{
328
  return (x << ((-y) & (__CHAR_BIT__ * __SIZEOF_SHORT__ - 1))) ^ (x >> y);
329
}
330
331
unsigned char
332
f55 (unsigned char x, int y)
333
{
334
  return (x << ((-y) & (__CHAR_BIT__ - 1))) ^ (x >> y);
335
}
336
337
unsigned char
338
f56 (unsigned char x, long int y)
339
{
340
  return (x << ((-y) & (__CHAR_BIT__ - 1))) ^ (x >> y);
341
}
342
343
unsigned int
344
f57 (unsigned int x, int y)
345
{
346
  return (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned int) - 1))) ^ (x >> y);
347
}
348
349
unsigned int
350
f58 (unsigned int x, long int y)
351
{
352
  return (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned int) - 1))) ^ (x >> y);
353
}
354
355
unsigned int
356
f59 (unsigned int x, int y __attribute__((unused)))
357
{
358
  return (x << ((-1) & (__CHAR_BIT__ * sizeof (unsigned int) - 1))) ^ (x >> 1);
359
}
360
361
unsigned int
362
f60 (unsigned int x, int y __attribute__((unused)))
363
{
364
  return (x << 1) ^ (x >> ((-1) & (__CHAR_BIT__ * sizeof (unsigned int) - 1)));
365
}
366
367
unsigned short int
368
f61 (unsigned short int x, int y)
369
{
370
  return (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned short) - 1))) ^ (x >> y);
371
}
372
373
unsigned short int
374
f62 (unsigned short int x, long int y)
375
{
376
  return (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned short) - 1))) ^ (x >> y);
377
}
378
379
unsigned char
380
f63 (unsigned char x, int y)
381
{
382
  return (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned char) - 1))) ^ (x >> y);
383
}
384
385
unsigned char
386
f64 (unsigned char x, long int y)
387
{
388
  return (x << ((-y) & (__CHAR_BIT__ * sizeof (unsigned char) - 1))) ^ (x >> y);
389
}
(-)gcc/testsuite/c-c++-common/rotate-4a.c.jj (+6 lines)
Line 0 Link Here
1
/* { dg-do run } */
2
/* { dg-options "-O2 -Wno-overflow" } */
3
4
#define ROTATE_N "rotate-4.c"
5
6
#include "rotate-1a.c"

Return to bug 57157