comparison gcc/graphite-sese-to-poly.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
comparison
equal deleted inserted replaced
111:04ced10e8804 131:84e7813d76e9
1 /* Conversion of SESE regions to Polyhedra. 1 /* Conversion of SESE regions to Polyhedra.
2 Copyright (C) 2009-2017 Free Software Foundation, Inc. 2 Copyright (C) 2009-2018 Free Software Foundation, Inc.
3 Contributed by Sebastian Pop <sebastian.pop@amd.com>. 3 Contributed by Sebastian Pop <sebastian.pop@amd.com>.
4 4
5 This file is part of GCC. 5 This file is part of GCC.
6 6
7 GCC is free software; you can redistribute it and/or modify 7 GCC is free software; you can redistribute it and/or modify
56 #include <isl/aff.h> 56 #include <isl/aff.h>
57 #include <isl/val.h> 57 #include <isl/val.h>
58 58
59 #include "graphite.h" 59 #include "graphite.h"
60 60
61 /* Assigns to RES the value of the INTEGER_CST T. */
62
63 static inline void
64 tree_int_to_gmp (tree t, mpz_t res)
65 {
66 wi::to_mpz (wi::to_wide (t), res, TYPE_SIGN (TREE_TYPE (t)));
67 }
68
69 /* Return an isl identifier for the polyhedral basic block PBB. */ 61 /* Return an isl identifier for the polyhedral basic block PBB. */
70 62
71 static isl_id * 63 static isl_id *
72 isl_id_for_pbb (scop_p s, poly_bb_p pbb) 64 isl_id_for_pbb (scop_p s, poly_bb_p pbb)
73 { 65 {
270 262
271 case BIT_NOT_EXPR: 263 case BIT_NOT_EXPR:
272 lhs = extract_affine (s, integer_minus_one_node, isl_space_copy (space)); 264 lhs = extract_affine (s, integer_minus_one_node, isl_space_copy (space));
273 rhs = extract_affine (s, TREE_OPERAND (e, 0), space); 265 rhs = extract_affine (s, TREE_OPERAND (e, 0), space);
274 res = isl_pw_aff_sub (lhs, rhs); 266 res = isl_pw_aff_sub (lhs, rhs);
275 break; 267 /* We need to always wrap the result of a bitwise operation. */
268 return wrap (res, TYPE_PRECISION (type) - (TYPE_UNSIGNED (type) ? 0 : 1));
276 269
277 case NEGATE_EXPR: 270 case NEGATE_EXPR:
278 lhs = extract_affine (s, TREE_OPERAND (e, 0), isl_space_copy (space)); 271 lhs = extract_affine (s, TREE_OPERAND (e, 0), isl_space_copy (space));
279 rhs = extract_affine (s, integer_minus_one_node, space); 272 rhs = extract_affine (s, integer_minus_one_node, space);
280 res = isl_pw_aff_mul (lhs, rhs); 273 res = isl_pw_aff_mul (lhs, rhs);
283 case SSA_NAME: 276 case SSA_NAME:
284 { 277 {
285 gcc_assert (! defined_in_sese_p (e, s->scop_info->region)); 278 gcc_assert (! defined_in_sese_p (e, s->scop_info->region));
286 int dim = parameter_index_in_region (e, s->scop_info); 279 int dim = parameter_index_in_region (e, s->scop_info);
287 gcc_assert (dim != -1); 280 gcc_assert (dim != -1);
288 res = extract_affine_name (dim, space); 281 /* No need to wrap a parameter. */
289 break; 282 return extract_affine_name (dim, space);
290 } 283 }
291 284
292 case INTEGER_CST: 285 case INTEGER_CST:
293 res = extract_affine_int (e, space); 286 res = extract_affine_int (e, space);
294 /* No need to wrap a single integer. */ 287 /* No need to wrap a single integer. */
299 tree itype = TREE_TYPE (TREE_OPERAND (e, 0)); 292 tree itype = TREE_TYPE (TREE_OPERAND (e, 0));
300 res = extract_affine (s, TREE_OPERAND (e, 0), space); 293 res = extract_affine (s, TREE_OPERAND (e, 0), space);
301 /* Signed values, even if overflow is undefined, get modulo-reduced. 294 /* Signed values, even if overflow is undefined, get modulo-reduced.
302 But only if not all values of the old type fit in the new. */ 295 But only if not all values of the old type fit in the new. */
303 if (! TYPE_UNSIGNED (type) 296 if (! TYPE_UNSIGNED (type)
304 && ((TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (e, 0))) 297 && ((TYPE_UNSIGNED (itype)
305 && TYPE_PRECISION (type) <= TYPE_PRECISION (itype)) 298 && TYPE_PRECISION (type) <= TYPE_PRECISION (itype))
306 || TYPE_PRECISION (type) < TYPE_PRECISION (itype))) 299 || TYPE_PRECISION (type) < TYPE_PRECISION (itype)))
307 res = wrap (res, TYPE_PRECISION (type) - 1); 300 res = wrap (res, TYPE_PRECISION (type) - 1);
308 break; 301 else if (TYPE_UNSIGNED (type)
302 && (!TYPE_UNSIGNED (itype)
303 || TYPE_PRECISION (type) < TYPE_PRECISION (itype)))
304 res = wrap (res, TYPE_PRECISION (type));
305 return res;
309 } 306 }
310 307
311 case NON_LVALUE_EXPR: 308 case NON_LVALUE_EXPR:
312 res = extract_affine (s, TREE_OPERAND (e, 0), space); 309 res = extract_affine (s, TREE_OPERAND (e, 0), space);
313 break; 310 break;
315 default: 312 default:
316 gcc_unreachable (); 313 gcc_unreachable ();
317 break; 314 break;
318 } 315 }
319 316
320 if (TYPE_UNSIGNED (type)) 317 /* For all wrapping arithmetic wrap the result. */
318 if (TYPE_OVERFLOW_WRAPS (type))
321 res = wrap (res, TYPE_PRECISION (type)); 319 res = wrap (res, TYPE_PRECISION (type));
322 320
323 return res; 321 return res;
324 } 322 }
325 323