comparison gcc/rtl-tests.c @ 132:d34655255c78

update gcc-8.2
author mir3636
date Thu, 25 Oct 2018 10:21:07 +0900 (2018-10-25)
parents 84e7813d76e9
children 1830386684a0
comparison
equal deleted inserted replaced
130:e108057fa461 132:d34655255c78
1 /* Unit tests for RTL-handling. 1 /* Unit tests for RTL-handling.
2 Copyright (C) 2015-2017 Free Software Foundation, Inc. 2 Copyright (C) 2015-2018 Free Software Foundation, Inc.
3 3
4 This file is part of GCC. 4 This file is part of GCC.
5 5
6 GCC is free software; you can redistribute it and/or modify it under 6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free 7 the terms of the GNU General Public License as published by the Free
226 ASSERT_RTL_DUMP_EQ ("(cjump_insn 1 (set (pc)\n" 226 ASSERT_RTL_DUMP_EQ ("(cjump_insn 1 (set (pc)\n"
227 " (label_ref 0)))\n", 227 " (label_ref 0)))\n",
228 jump_insn); 228 jump_insn);
229 } 229 }
230 230
231 template<unsigned int N>
232 struct const_poly_int_tests
233 {
234 static void run ();
235 };
236
237 template<>
238 struct const_poly_int_tests<1>
239 {
240 static void run () {}
241 };
242
243 /* Test various CONST_POLY_INT properties. */
244
245 template<unsigned int N>
246 void
247 const_poly_int_tests<N>::run ()
248 {
249 rtx x1 = gen_int_mode (poly_int64 (1, 1), QImode);
250 rtx x255 = gen_int_mode (poly_int64 (1, 255), QImode);
251
252 /* Test that constants are unique. */
253 ASSERT_EQ (x1, gen_int_mode (poly_int64 (1, 1), QImode));
254 ASSERT_NE (x1, gen_int_mode (poly_int64 (1, 1), HImode));
255 ASSERT_NE (x1, x255);
256
257 /* Test const_poly_int_value. */
258 ASSERT_KNOWN_EQ (const_poly_int_value (x1), poly_int64 (1, 1));
259 ASSERT_KNOWN_EQ (const_poly_int_value (x255), poly_int64 (1, -1));
260
261 /* Test rtx_to_poly_int64. */
262 ASSERT_KNOWN_EQ (rtx_to_poly_int64 (x1), poly_int64 (1, 1));
263 ASSERT_KNOWN_EQ (rtx_to_poly_int64 (x255), poly_int64 (1, -1));
264 ASSERT_MAYBE_NE (rtx_to_poly_int64 (x255), poly_int64 (1, 255));
265
266 /* Test plus_constant of a symbol. */
267 rtx symbol = gen_rtx_SYMBOL_REF (Pmode, "foo");
268 rtx offset1 = gen_int_mode (poly_int64 (9, 11), Pmode);
269 rtx sum1 = gen_rtx_CONST (Pmode, gen_rtx_PLUS (Pmode, symbol, offset1));
270 ASSERT_RTX_EQ (plus_constant (Pmode, symbol, poly_int64 (9, 11)), sum1);
271
272 /* Test plus_constant of a CONST. */
273 rtx offset2 = gen_int_mode (poly_int64 (12, 20), Pmode);
274 rtx sum2 = gen_rtx_CONST (Pmode, gen_rtx_PLUS (Pmode, symbol, offset2));
275 ASSERT_RTX_EQ (plus_constant (Pmode, sum1, poly_int64 (3, 9)), sum2);
276
277 /* Test a cancelling plus_constant. */
278 ASSERT_EQ (plus_constant (Pmode, sum2, poly_int64 (-12, -20)), symbol);
279
280 /* Test plus_constant on integer constants. */
281 ASSERT_EQ (plus_constant (QImode, const1_rtx, poly_int64 (4, -2)),
282 gen_int_mode (poly_int64 (5, -2), QImode));
283 ASSERT_EQ (plus_constant (QImode, x1, poly_int64 (4, -2)),
284 gen_int_mode (poly_int64 (5, -1), QImode));
285 }
286
287 /* Check dumping of repeated RTL vectors. */
288
289 static void
290 test_dumping_repeat ()
291 {
292 rtx p = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (3));
293 XVECEXP (p, 0, 0) = const0_rtx;
294 XVECEXP (p, 0, 1) = const0_rtx;
295 XVECEXP (p, 0, 2) = const0_rtx;
296 ASSERT_RTL_DUMP_EQ ("(parallel [\n"
297 " (const_int 0) repeated x3\n"
298 " ])",
299 p);
300
301 XVECEXP (p, 0, 1) = const1_rtx;
302 ASSERT_RTL_DUMP_EQ ("(parallel [\n"
303 " (const_int 0)\n"
304 " (const_int 1)\n"
305 " (const_int 0)\n"
306 " ])",
307 p);
308 }
309
231 /* Run all of the selftests within this file. */ 310 /* Run all of the selftests within this file. */
232 311
233 void 312 void
234 rtl_tests_c_tests () 313 rtl_tests_c_tests ()
235 { 314 {
236 test_dumping_regs (); 315 test_dumping_regs ();
237 test_dumping_insns (); 316 test_dumping_insns ();
238 test_dumping_rtx_reuse (); 317 test_dumping_rtx_reuse ();
239 test_single_set (); 318 test_single_set ();
240 test_uncond_jump (); 319 test_uncond_jump ();
320 const_poly_int_tests<NUM_POLY_INT_COEFFS>::run ();
321 test_dumping_repeat ();
241 322
242 /* Purge state. */ 323 /* Purge state. */
243 set_first_insn (NULL); 324 set_first_insn (NULL);
244 set_last_insn (NULL); 325 set_last_insn (NULL);
245 } 326 }