Default to dwarf version 4 on hppa64-hpux
[official-gcc.git] / gcc / gimple-range-fold.cc
blobbb09b751a4e628749131e898c78c42fc470396ea
1 /* Code for GIMPLE range related routines.
2 Copyright (C) 2019-2021 Free Software Foundation, Inc.
3 Contributed by Andrew MacLeod <amacleod@redhat.com>
4 and Aldy Hernandez <aldyh@redhat.com>.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
11 any later version.
13 GCC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 #include "config.h"
23 #include "system.h"
24 #include "coretypes.h"
25 #include "backend.h"
26 #include "insn-codes.h"
27 #include "tree.h"
28 #include "gimple.h"
29 #include "ssa.h"
30 #include "gimple-pretty-print.h"
31 #include "optabs-tree.h"
32 #include "gimple-fold.h"
33 #include "wide-int.h"
34 #include "fold-const.h"
35 #include "case-cfn-macros.h"
36 #include "omp-general.h"
37 #include "cfgloop.h"
38 #include "tree-ssa-loop.h"
39 #include "tree-scalar-evolution.h"
40 #include "langhooks.h"
41 #include "vr-values.h"
42 #include "range.h"
43 #include "value-query.h"
44 #include "range-op.h"
45 #include "gimple-range.h"
46 // Construct a fur_source, and set the m_query field.
48 fur_source::fur_source (range_query *q)
50 if (q)
51 m_query = q;
52 else if (cfun)
53 m_query = get_range_query (cfun);
54 else
55 m_query = get_global_range_query ();
56 m_gori = NULL;
59 // Invoke range_of_expr on EXPR.
61 bool
62 fur_source::get_operand (irange &r, tree expr)
64 return m_query->range_of_expr (r, expr);
67 // Evaluate EXPR for this stmt as a PHI argument on edge E. Use the current
68 // range_query to get the range on the edge.
70 bool
71 fur_source::get_phi_operand (irange &r, tree expr, edge e)
73 return m_query->range_on_edge (r, e, expr);
76 // Default is no relation.
78 relation_kind
79 fur_source::query_relation (tree op1 ATTRIBUTE_UNUSED,
80 tree op2 ATTRIBUTE_UNUSED)
82 return VREL_NONE;
85 // Default registers nothing.
87 void
88 fur_source::register_relation (gimple *s ATTRIBUTE_UNUSED,
89 relation_kind k ATTRIBUTE_UNUSED,
90 tree op1 ATTRIBUTE_UNUSED,
91 tree op2 ATTRIBUTE_UNUSED)
95 // Default registers nothing.
97 void
98 fur_source::register_relation (edge e ATTRIBUTE_UNUSED,
99 relation_kind k ATTRIBUTE_UNUSED,
100 tree op1 ATTRIBUTE_UNUSED,
101 tree op2 ATTRIBUTE_UNUSED)
105 // This version of fur_source will pick a range up off an edge.
107 class fur_edge : public fur_source
109 public:
110 fur_edge (edge e, range_query *q = NULL);
111 virtual bool get_operand (irange &r, tree expr) OVERRIDE;
112 virtual bool get_phi_operand (irange &r, tree expr, edge e) OVERRIDE;
113 private:
114 edge m_edge;
117 // Instantiate an edge based fur_source.
119 inline
120 fur_edge::fur_edge (edge e, range_query *q) : fur_source (q)
122 m_edge = e;
125 // Get the value of EXPR on edge m_edge.
127 bool
128 fur_edge::get_operand (irange &r, tree expr)
130 return m_query->range_on_edge (r, m_edge, expr);
133 // Evaluate EXPR for this stmt as a PHI argument on edge E. Use the current
134 // range_query to get the range on the edge.
136 bool
137 fur_edge::get_phi_operand (irange &r, tree expr, edge e)
139 // Edge to edge recalculations not supoprted yet, until we sort it out.
140 gcc_checking_assert (e == m_edge);
141 return m_query->range_on_edge (r, e, expr);
144 // Instantiate a stmt based fur_source.
146 fur_stmt::fur_stmt (gimple *s, range_query *q) : fur_source (q)
148 m_stmt = s;
151 // Retreive range of EXPR as it occurs as a use on stmt M_STMT.
153 bool
154 fur_stmt::get_operand (irange &r, tree expr)
156 return m_query->range_of_expr (r, expr, m_stmt);
159 // Evaluate EXPR for this stmt as a PHI argument on edge E. Use the current
160 // range_query to get the range on the edge.
162 bool
163 fur_stmt::get_phi_operand (irange &r, tree expr, edge e)
165 // Pick up the range of expr from edge E.
166 fur_edge e_src (e, m_query);
167 return e_src.get_operand (r, expr);
170 // Return relation based from m_stmt.
172 relation_kind
173 fur_stmt::query_relation (tree op1, tree op2)
175 return m_query->query_relation (m_stmt, op1, op2);
178 // Instantiate a stmt based fur_source with a GORI object.
181 fur_depend::fur_depend (gimple *s, gori_compute *gori, range_query *q)
182 : fur_stmt (s, q)
184 gcc_checking_assert (gori);
185 m_gori = gori;
186 // Set relations if there is an oracle in the range_query.
187 // This will enable registering of relationships as they are discovered.
188 m_oracle = q->oracle ();
192 // Register a relation on a stmt if there is an oracle.
194 void
195 fur_depend::register_relation (gimple *s, relation_kind k, tree op1, tree op2)
197 if (m_oracle)
198 m_oracle->register_stmt (s, k, op1, op2);
201 // Register a relation on an edge if there is an oracle.
203 void
204 fur_depend::register_relation (edge e, relation_kind k, tree op1, tree op2)
206 if (m_oracle)
207 m_oracle->register_edge (e, k, op1, op2);
210 // This version of fur_source will pick a range up from a list of ranges
211 // supplied by the caller.
213 class fur_list : public fur_source
215 public:
216 fur_list (irange &r1);
217 fur_list (irange &r1, irange &r2);
218 fur_list (unsigned num, irange *list);
219 virtual bool get_operand (irange &r, tree expr) OVERRIDE;
220 virtual bool get_phi_operand (irange &r, tree expr, edge e) OVERRIDE;
221 private:
222 int_range_max m_local[2];
223 irange *m_list;
224 unsigned m_index;
225 unsigned m_limit;
228 // One range supplied for unary operations.
230 fur_list::fur_list (irange &r1) : fur_source (NULL)
232 m_list = m_local;
233 m_index = 0;
234 m_limit = 1;
235 m_local[0] = r1;
238 // Two ranges supplied for binary operations.
240 fur_list::fur_list (irange &r1, irange &r2) : fur_source (NULL)
242 m_list = m_local;
243 m_index = 0;
244 m_limit = 2;
245 m_local[0] = r1;
246 m_local[0] = r2;
249 // Arbitrary number of ranges in a vector.
251 fur_list::fur_list (unsigned num, irange *list) : fur_source (NULL)
253 m_list = list;
254 m_index = 0;
255 m_limit = num;
258 // Get the next operand from the vector, ensure types are compatible.
260 bool
261 fur_list::get_operand (irange &r, tree expr)
263 if (m_index >= m_limit)
264 return m_query->range_of_expr (r, expr);
265 r = m_list[m_index++];
266 gcc_checking_assert (range_compatible_p (TREE_TYPE (expr), r.type ()));
267 return true;
270 // This will simply pick the next operand from the vector.
271 bool
272 fur_list::get_phi_operand (irange &r, tree expr, edge e ATTRIBUTE_UNUSED)
274 return get_operand (r, expr);
277 // Fold stmt S into range R using R1 as the first operand.
279 bool
280 fold_range (irange &r, gimple *s, irange &r1)
282 fold_using_range f;
283 fur_list src (r1);
284 return f.fold_stmt (r, s, src);
287 // Fold stmt S into range R using R1 and R2 as the first two operands.
289 bool
290 fold_range (irange &r, gimple *s, irange &r1, irange &r2)
292 fold_using_range f;
293 fur_list src (r1, r2);
294 return f.fold_stmt (r, s, src);
297 // Fold stmt S into range R using NUM_ELEMENTS from VECTOR as the initial
298 // operands encountered.
300 bool
301 fold_range (irange &r, gimple *s, unsigned num_elements, irange *vector)
303 fold_using_range f;
304 fur_list src (num_elements, vector);
305 return f.fold_stmt (r, s, src);
308 // Fold stmt S into range R using range query Q.
310 bool
311 fold_range (irange &r, gimple *s, range_query *q)
313 fold_using_range f;
314 fur_stmt src (s, q);
315 return f.fold_stmt (r, s, src);
318 // Recalculate stmt S into R using range query Q as if it were on edge ON_EDGE.
320 bool
321 fold_range (irange &r, gimple *s, edge on_edge, range_query *q)
323 fold_using_range f;
324 fur_edge src (on_edge, q);
325 return f.fold_stmt (r, s, src);
328 // -------------------------------------------------------------------------
330 // Adjust the range for a pointer difference where the operands came
331 // from a memchr.
333 // This notices the following sequence:
335 // def = __builtin_memchr (arg, 0, sz)
336 // n = def - arg
338 // The range for N can be narrowed to [0, PTRDIFF_MAX - 1].
340 static void
341 adjust_pointer_diff_expr (irange &res, const gimple *diff_stmt)
343 tree op0 = gimple_assign_rhs1 (diff_stmt);
344 tree op1 = gimple_assign_rhs2 (diff_stmt);
345 tree op0_ptype = TREE_TYPE (TREE_TYPE (op0));
346 tree op1_ptype = TREE_TYPE (TREE_TYPE (op1));
347 gimple *call;
349 if (TREE_CODE (op0) == SSA_NAME
350 && TREE_CODE (op1) == SSA_NAME
351 && (call = SSA_NAME_DEF_STMT (op0))
352 && is_gimple_call (call)
353 && gimple_call_builtin_p (call, BUILT_IN_MEMCHR)
354 && TYPE_MODE (op0_ptype) == TYPE_MODE (char_type_node)
355 && TYPE_PRECISION (op0_ptype) == TYPE_PRECISION (char_type_node)
356 && TYPE_MODE (op1_ptype) == TYPE_MODE (char_type_node)
357 && TYPE_PRECISION (op1_ptype) == TYPE_PRECISION (char_type_node)
358 && gimple_call_builtin_p (call, BUILT_IN_MEMCHR)
359 && vrp_operand_equal_p (op1, gimple_call_arg (call, 0))
360 && integer_zerop (gimple_call_arg (call, 1)))
362 tree max = vrp_val_max (ptrdiff_type_node);
363 wide_int wmax = wi::to_wide (max, TYPE_PRECISION (TREE_TYPE (max)));
364 tree expr_type = gimple_range_type (diff_stmt);
365 tree range_min = build_zero_cst (expr_type);
366 tree range_max = wide_int_to_tree (expr_type, wmax - 1);
367 int_range<2> r (range_min, range_max);
368 res.intersect (r);
372 // Adjust the range for an IMAGPART_EXPR.
374 static void
375 adjust_imagpart_expr (irange &res, const gimple *stmt)
377 tree name = TREE_OPERAND (gimple_assign_rhs1 (stmt), 0);
379 if (TREE_CODE (name) != SSA_NAME || !SSA_NAME_DEF_STMT (name))
380 return;
382 gimple *def_stmt = SSA_NAME_DEF_STMT (name);
383 if (is_gimple_call (def_stmt) && gimple_call_internal_p (def_stmt))
385 switch (gimple_call_internal_fn (def_stmt))
387 case IFN_ADD_OVERFLOW:
388 case IFN_SUB_OVERFLOW:
389 case IFN_MUL_OVERFLOW:
390 case IFN_ATOMIC_COMPARE_EXCHANGE:
392 int_range<2> r;
393 r.set_varying (boolean_type_node);
394 tree type = TREE_TYPE (gimple_assign_lhs (stmt));
395 range_cast (r, type);
396 res.intersect (r);
398 default:
399 break;
401 return;
403 if (is_gimple_assign (def_stmt))
405 tree cst = gimple_assign_rhs1 (def_stmt);
406 if (TREE_CODE (cst) == COMPLEX_CST)
408 tree imag = TREE_IMAGPART (cst);
409 int_range<2> tmp (imag, imag);
410 res.intersect (tmp);
415 // Adjust the range for a REALPART_EXPR.
417 static void
418 adjust_realpart_expr (irange &res, const gimple *stmt)
420 tree name = TREE_OPERAND (gimple_assign_rhs1 (stmt), 0);
422 if (TREE_CODE (name) != SSA_NAME)
423 return;
425 gimple *def_stmt = SSA_NAME_DEF_STMT (name);
426 if (!SSA_NAME_DEF_STMT (name))
427 return;
429 if (is_gimple_assign (def_stmt))
431 tree cst = gimple_assign_rhs1 (def_stmt);
432 if (TREE_CODE (cst) == COMPLEX_CST)
434 tree imag = TREE_REALPART (cst);
435 int_range<2> tmp (imag, imag);
436 res.intersect (tmp);
441 // This function looks for situations when walking the use/def chains
442 // may provide additonal contextual range information not exposed on
443 // this statement.
445 static void
446 gimple_range_adjustment (irange &res, const gimple *stmt)
448 switch (gimple_expr_code (stmt))
450 case POINTER_DIFF_EXPR:
451 adjust_pointer_diff_expr (res, stmt);
452 return;
454 case IMAGPART_EXPR:
455 adjust_imagpart_expr (res, stmt);
456 return;
458 case REALPART_EXPR:
459 adjust_realpart_expr (res, stmt);
460 return;
462 default:
463 break;
467 // Return the base of the RHS of an assignment.
469 static tree
470 gimple_range_base_of_assignment (const gimple *stmt)
472 gcc_checking_assert (gimple_code (stmt) == GIMPLE_ASSIGN);
473 tree op1 = gimple_assign_rhs1 (stmt);
474 if (gimple_assign_rhs_code (stmt) == ADDR_EXPR)
475 return get_base_address (TREE_OPERAND (op1, 0));
476 return op1;
479 // Return the first operand of this statement if it is a valid operand
480 // supported by ranges, otherwise return NULL_TREE. Special case is
481 // &(SSA_NAME expr), return the SSA_NAME instead of the ADDR expr.
483 tree
484 gimple_range_operand1 (const gimple *stmt)
486 gcc_checking_assert (gimple_range_handler (stmt));
488 switch (gimple_code (stmt))
490 case GIMPLE_COND:
491 return gimple_cond_lhs (stmt);
492 case GIMPLE_ASSIGN:
494 tree base = gimple_range_base_of_assignment (stmt);
495 if (base && TREE_CODE (base) == MEM_REF)
497 // If the base address is an SSA_NAME, we return it
498 // here. This allows processing of the range of that
499 // name, while the rest of the expression is simply
500 // ignored. The code in range_ops will see the
501 // ADDR_EXPR and do the right thing.
502 tree ssa = TREE_OPERAND (base, 0);
503 if (TREE_CODE (ssa) == SSA_NAME)
504 return ssa;
506 return base;
508 default:
509 break;
511 return NULL;
514 // Return the second operand of statement STMT, otherwise return NULL_TREE.
516 tree
517 gimple_range_operand2 (const gimple *stmt)
519 gcc_checking_assert (gimple_range_handler (stmt));
521 switch (gimple_code (stmt))
523 case GIMPLE_COND:
524 return gimple_cond_rhs (stmt);
525 case GIMPLE_ASSIGN:
526 if (gimple_num_ops (stmt) >= 3)
527 return gimple_assign_rhs2 (stmt);
528 default:
529 break;
531 return NULL_TREE;
534 // Calculate a range for statement S and return it in R. If NAME is provided it
535 // represents the SSA_NAME on the LHS of the statement. It is only required
536 // if there is more than one lhs/output. If a range cannot
537 // be calculated, return false.
539 bool
540 fold_using_range::fold_stmt (irange &r, gimple *s, fur_source &src, tree name)
542 bool res = false;
543 // If name and S are specified, make sure it is an LHS of S.
544 gcc_checking_assert (!name || !gimple_get_lhs (s) ||
545 name == gimple_get_lhs (s));
547 if (!name)
548 name = gimple_get_lhs (s);
550 // Process addresses.
551 if (gimple_code (s) == GIMPLE_ASSIGN
552 && gimple_assign_rhs_code (s) == ADDR_EXPR)
553 return range_of_address (r, s, src);
555 if (gimple_range_handler (s))
556 res = range_of_range_op (r, s, src);
557 else if (is_a<gphi *>(s))
558 res = range_of_phi (r, as_a<gphi *> (s), src);
559 else if (is_a<gcall *>(s))
560 res = range_of_call (r, as_a<gcall *> (s), src);
561 else if (is_a<gassign *> (s) && gimple_assign_rhs_code (s) == COND_EXPR)
562 res = range_of_cond_expr (r, as_a<gassign *> (s), src);
564 if (!res)
566 // If no name specified or range is unsupported, bail.
567 if (!name || !gimple_range_ssa_p (name))
568 return false;
569 // We don't understand the stmt, so return the global range.
570 r = gimple_range_global (name);
571 return true;
574 if (r.undefined_p ())
575 return true;
577 // We sometimes get compatible types copied from operands, make sure
578 // the correct type is being returned.
579 if (name && TREE_TYPE (name) != r.type ())
581 gcc_checking_assert (range_compatible_p (r.type (), TREE_TYPE (name)));
582 range_cast (r, TREE_TYPE (name));
584 return true;
587 // Calculate a range for range_op statement S and return it in R. If any
588 // If a range cannot be calculated, return false.
590 bool
591 fold_using_range::range_of_range_op (irange &r, gimple *s, fur_source &src)
593 int_range_max range1, range2;
594 tree type = gimple_range_type (s);
595 if (!type)
596 return false;
597 range_operator *handler = gimple_range_handler (s);
598 gcc_checking_assert (handler);
600 tree lhs = gimple_get_lhs (s);
601 tree op1 = gimple_range_operand1 (s);
602 tree op2 = gimple_range_operand2 (s);
604 if (src.get_operand (range1, op1))
606 if (!op2)
608 // Fold range, and register any dependency if available.
609 int_range<2> r2 (type);
610 handler->fold_range (r, type, range1, r2);
611 if (lhs && gimple_range_ssa_p (op1))
613 if (src.gori ())
614 src.gori ()->register_dependency (lhs, op1);
615 relation_kind rel;
616 rel = handler->lhs_op1_relation (r, range1, range1);
617 if (rel != VREL_NONE)
618 src.register_relation (s, rel, lhs, op1);
621 else if (src.get_operand (range2, op2))
623 relation_kind rel = src.query_relation (op1, op2);
624 if (dump_file && (dump_flags & TDF_DETAILS) && rel != VREL_NONE)
626 fprintf (dump_file, " folding with relation ");
627 print_relation (dump_file, rel);
628 fputc ('\n', dump_file);
630 // Fold range, and register any dependency if available.
631 handler->fold_range (r, type, range1, range2, rel);
632 relation_fold_and_or (r, s, src);
633 if (lhs)
635 if (src.gori ())
637 src.gori ()->register_dependency (lhs, op1);
638 src.gori ()->register_dependency (lhs, op2);
640 if (gimple_range_ssa_p (op1))
642 rel = handler->lhs_op1_relation (r, range1, range2);
643 if (rel != VREL_NONE)
644 src.register_relation (s, rel, lhs, op1);
646 if (gimple_range_ssa_p (op2))
648 rel= handler->lhs_op2_relation (r, range1, range2);
649 if (rel != VREL_NONE)
650 src.register_relation (s, rel, lhs, op2);
653 // Check for an existing BB, as we maybe asked to fold an
654 // artificial statement not in the CFG.
655 else if (is_a<gcond *> (s) && gimple_bb (s))
657 basic_block bb = gimple_bb (s);
658 edge e0 = EDGE_SUCC (bb, 0);
659 edge e1 = EDGE_SUCC (bb, 1);
661 if (!single_pred_p (e0->dest))
662 e0 = NULL;
663 if (!single_pred_p (e1->dest))
664 e1 = NULL;
665 src.register_outgoing_edges (as_a<gcond *> (s), r, e0, e1);
668 else
669 r.set_varying (type);
671 else
672 r.set_varying (type);
673 // Make certain range-op adjustments that aren't handled any other way.
674 gimple_range_adjustment (r, s);
675 return true;
678 // Calculate the range of an assignment containing an ADDR_EXPR.
679 // Return the range in R.
680 // If a range cannot be calculated, set it to VARYING and return true.
682 bool
683 fold_using_range::range_of_address (irange &r, gimple *stmt, fur_source &src)
685 gcc_checking_assert (gimple_code (stmt) == GIMPLE_ASSIGN);
686 gcc_checking_assert (gimple_assign_rhs_code (stmt) == ADDR_EXPR);
688 bool strict_overflow_p;
689 tree expr = gimple_assign_rhs1 (stmt);
690 poly_int64 bitsize, bitpos;
691 tree offset;
692 machine_mode mode;
693 int unsignedp, reversep, volatilep;
694 tree base = get_inner_reference (TREE_OPERAND (expr, 0), &bitsize,
695 &bitpos, &offset, &mode, &unsignedp,
696 &reversep, &volatilep);
699 if (base != NULL_TREE
700 && TREE_CODE (base) == MEM_REF
701 && TREE_CODE (TREE_OPERAND (base, 0)) == SSA_NAME)
703 tree ssa = TREE_OPERAND (base, 0);
704 tree lhs = gimple_get_lhs (stmt);
705 if (lhs && gimple_range_ssa_p (ssa) && src.gori ())
706 src.gori ()->register_dependency (lhs, ssa);
707 gcc_checking_assert (irange::supports_type_p (TREE_TYPE (ssa)));
708 src.get_operand (r, ssa);
709 range_cast (r, TREE_TYPE (gimple_assign_rhs1 (stmt)));
711 poly_offset_int off = 0;
712 bool off_cst = false;
713 if (offset == NULL_TREE || TREE_CODE (offset) == INTEGER_CST)
715 off = mem_ref_offset (base);
716 if (offset)
717 off += poly_offset_int::from (wi::to_poly_wide (offset),
718 SIGNED);
719 off <<= LOG2_BITS_PER_UNIT;
720 off += bitpos;
721 off_cst = true;
723 /* If &X->a is equal to X, the range of X is the result. */
724 if (off_cst && known_eq (off, 0))
725 return true;
726 else if (flag_delete_null_pointer_checks
727 && !TYPE_OVERFLOW_WRAPS (TREE_TYPE (expr)))
729 /* For -fdelete-null-pointer-checks -fno-wrapv-pointer we don't
730 allow going from non-NULL pointer to NULL. */
731 if(!range_includes_zero_p (&r))
732 return true;
734 /* If MEM_REF has a "positive" offset, consider it non-NULL
735 always, for -fdelete-null-pointer-checks also "negative"
736 ones. Punt for unknown offsets (e.g. variable ones). */
737 if (!TYPE_OVERFLOW_WRAPS (TREE_TYPE (expr))
738 && off_cst
739 && known_ne (off, 0)
740 && (flag_delete_null_pointer_checks || known_gt (off, 0)))
742 r = range_nonzero (TREE_TYPE (gimple_assign_rhs1 (stmt)));
743 return true;
745 r = int_range<2> (TREE_TYPE (gimple_assign_rhs1 (stmt)));
746 return true;
749 // Handle "= &a".
750 if (tree_single_nonzero_warnv_p (expr, &strict_overflow_p))
752 r = range_nonzero (TREE_TYPE (gimple_assign_rhs1 (stmt)));
753 return true;
756 // Otherwise return varying.
757 r = int_range<2> (TREE_TYPE (gimple_assign_rhs1 (stmt)));
758 return true;
761 // Calculate a range for phi statement S and return it in R.
762 // If a range cannot be calculated, return false.
764 bool
765 fold_using_range::range_of_phi (irange &r, gphi *phi, fur_source &src)
767 tree phi_def = gimple_phi_result (phi);
768 tree type = gimple_range_type (phi);
769 int_range_max arg_range;
770 unsigned x;
772 if (!type)
773 return false;
775 // Track if all executable arguments are the same.
776 tree single_arg = NULL_TREE;
777 bool seen_arg = false;
779 // Start with an empty range, unioning in each argument's range.
780 r.set_undefined ();
781 for (x = 0; x < gimple_phi_num_args (phi); x++)
783 tree arg = gimple_phi_arg_def (phi, x);
784 edge e = gimple_phi_arg_edge (phi, x);
786 // Get the range of the argument on its edge.
787 src.get_phi_operand (arg_range, arg, e);
789 if (!arg_range.undefined_p ())
791 // Register potential dependencies for stale value tracking.
792 r.union_ (arg_range);
793 if (gimple_range_ssa_p (arg) && src.gori ())
794 src.gori ()->register_dependency (phi_def, arg);
796 // Track if all arguments are the same.
797 if (!seen_arg)
799 seen_arg = true;
800 single_arg = arg;
802 else if (single_arg != arg)
803 single_arg = NULL_TREE;
806 // Once the value reaches varying, stop looking.
807 if (r.varying_p () && single_arg == NULL_TREE)
808 break;
811 // If the PHI boils down to a single effective argument, look at it.
812 if (single_arg)
814 // Symbolic arguments are equivalences.
815 if (gimple_range_ssa_p (single_arg))
816 src.register_relation (phi, EQ_EXPR, phi_def, single_arg);
817 else if (src.get_operand (arg_range, single_arg)
818 && arg_range.singleton_p ())
820 // Numerical arguments that are a constant can be returned as
821 // the constant. This can help fold later cases where even this
822 // constant might have been UNDEFINED via an unreachable edge.
823 r = arg_range;
824 return true;
828 // If SCEV is available, query if this PHI has any knonwn values.
829 if (scev_initialized_p () && !POINTER_TYPE_P (TREE_TYPE (phi_def)))
831 value_range loop_range;
832 class loop *l = loop_containing_stmt (phi);
833 if (l && loop_outer (l))
835 range_of_ssa_name_with_loop_info (loop_range, phi_def, l, phi, src);
836 if (!loop_range.varying_p ())
838 if (dump_file && (dump_flags & TDF_DETAILS))
840 fprintf (dump_file, " Loops range found for ");
841 print_generic_expr (dump_file, phi_def, TDF_SLIM);
842 fprintf (dump_file, ": ");
843 loop_range.dump (dump_file);
844 fprintf (dump_file, " and calculated range :");
845 r.dump (dump_file);
846 fprintf (dump_file, "\n");
848 r.intersect (loop_range);
853 return true;
856 // Calculate a range for call statement S and return it in R.
857 // If a range cannot be calculated, return false.
859 bool
860 fold_using_range::range_of_call (irange &r, gcall *call, fur_source &src)
862 tree type = gimple_range_type (call);
863 if (!type)
864 return false;
866 tree lhs = gimple_call_lhs (call);
867 bool strict_overflow_p;
869 if (range_of_builtin_call (r, call, src))
871 else if (gimple_stmt_nonnegative_warnv_p (call, &strict_overflow_p))
872 r.set (build_int_cst (type, 0), TYPE_MAX_VALUE (type));
873 else if (gimple_call_nonnull_result_p (call)
874 || gimple_call_nonnull_arg (call))
875 r = range_nonzero (type);
876 else
877 r.set_varying (type);
879 // If there is an LHS, intersect that with what is known.
880 if (lhs)
882 value_range def;
883 def = gimple_range_global (lhs);
884 r.intersect (def);
886 return true;
889 // Return the range of a __builtin_ubsan* in CALL and set it in R.
890 // CODE is the type of ubsan call (PLUS_EXPR, MINUS_EXPR or
891 // MULT_EXPR).
893 void
894 fold_using_range::range_of_builtin_ubsan_call (irange &r, gcall *call,
895 tree_code code, fur_source &src)
897 gcc_checking_assert (code == PLUS_EXPR || code == MINUS_EXPR
898 || code == MULT_EXPR);
899 tree type = gimple_range_type (call);
900 range_operator *op = range_op_handler (code, type);
901 gcc_checking_assert (op);
902 int_range_max ir0, ir1;
903 tree arg0 = gimple_call_arg (call, 0);
904 tree arg1 = gimple_call_arg (call, 1);
905 src.get_operand (ir0, arg0);
906 src.get_operand (ir1, arg1);
907 // Check for any relation between arg0 and arg1.
908 relation_kind relation = src.query_relation (arg0, arg1);
910 bool saved_flag_wrapv = flag_wrapv;
911 // Pretend the arithmetic is wrapping. If there is any overflow,
912 // we'll complain, but will actually do wrapping operation.
913 flag_wrapv = 1;
914 op->fold_range (r, type, ir0, ir1, relation);
915 flag_wrapv = saved_flag_wrapv;
917 // If for both arguments vrp_valueize returned non-NULL, this should
918 // have been already folded and if not, it wasn't folded because of
919 // overflow. Avoid removing the UBSAN_CHECK_* calls in that case.
920 if (r.singleton_p ())
921 r.set_varying (type);
924 // Return TRUE if we recognize the target character set and return the
925 // range for lower case and upper case letters.
927 static bool
928 get_letter_range (tree type, irange &lowers, irange &uppers)
930 // ASCII
931 int a = lang_hooks.to_target_charset ('a');
932 int z = lang_hooks.to_target_charset ('z');
933 int A = lang_hooks.to_target_charset ('A');
934 int Z = lang_hooks.to_target_charset ('Z');
936 if ((z - a == 25) && (Z - A == 25))
938 lowers = int_range<2> (build_int_cst (type, a), build_int_cst (type, z));
939 uppers = int_range<2> (build_int_cst (type, A), build_int_cst (type, Z));
940 return true;
942 // Unknown character set.
943 return false;
946 // For a builtin in CALL, return a range in R if known and return
947 // TRUE. Otherwise return FALSE.
949 bool
950 fold_using_range::range_of_builtin_call (irange &r, gcall *call,
951 fur_source &src)
953 combined_fn func = gimple_call_combined_fn (call);
954 if (func == CFN_LAST)
955 return false;
957 tree type = gimple_range_type (call);
958 tree arg;
959 int mini, maxi, zerov = 0, prec;
960 scalar_int_mode mode;
962 switch (func)
964 case CFN_BUILT_IN_CONSTANT_P:
965 if (cfun->after_inlining)
967 r.set_zero (type);
968 // r.equiv_clear ();
969 return true;
971 arg = gimple_call_arg (call, 0);
972 if (src.get_operand (r, arg) && r.singleton_p ())
974 r.set (build_one_cst (type), build_one_cst (type));
975 return true;
977 break;
979 case CFN_BUILT_IN_TOUPPER:
981 arg = gimple_call_arg (call, 0);
982 // If the argument isn't compatible with the LHS, do nothing.
983 if (!range_compatible_p (type, TREE_TYPE (arg)))
984 return false;
985 if (!src.get_operand (r, arg))
986 return false;
988 int_range<3> lowers;
989 int_range<3> uppers;
990 if (!get_letter_range (type, lowers, uppers))
991 return false;
993 // Return the range passed in without any lower case characters,
994 // but including all the upper case ones.
995 lowers.invert ();
996 r.intersect (lowers);
997 r.union_ (uppers);
998 return true;
1001 case CFN_BUILT_IN_TOLOWER:
1003 arg = gimple_call_arg (call, 0);
1004 // If the argument isn't compatible with the LHS, do nothing.
1005 if (!range_compatible_p (type, TREE_TYPE (arg)))
1006 return false;
1007 if (!src.get_operand (r, arg))
1008 return false;
1010 int_range<3> lowers;
1011 int_range<3> uppers;
1012 if (!get_letter_range (type, lowers, uppers))
1013 return false;
1015 // Return the range passed in without any upper case characters,
1016 // but including all the lower case ones.
1017 uppers.invert ();
1018 r.intersect (uppers);
1019 r.union_ (lowers);
1020 return true;
1023 CASE_CFN_FFS:
1024 CASE_CFN_POPCOUNT:
1025 // __builtin_ffs* and __builtin_popcount* return [0, prec].
1026 arg = gimple_call_arg (call, 0);
1027 prec = TYPE_PRECISION (TREE_TYPE (arg));
1028 mini = 0;
1029 maxi = prec;
1030 src.get_operand (r, arg);
1031 // If arg is non-zero, then ffs or popcount are non-zero.
1032 if (!range_includes_zero_p (&r))
1033 mini = 1;
1034 // If some high bits are known to be zero, decrease the maximum.
1035 if (!r.undefined_p ())
1037 if (TYPE_SIGN (r.type ()) == SIGNED)
1038 range_cast (r, unsigned_type_for (r.type ()));
1039 wide_int max = r.upper_bound ();
1040 maxi = wi::floor_log2 (max) + 1;
1042 r.set (build_int_cst (type, mini), build_int_cst (type, maxi));
1043 return true;
1045 CASE_CFN_PARITY:
1046 r.set (build_zero_cst (type), build_one_cst (type));
1047 return true;
1049 CASE_CFN_CLZ:
1050 // __builtin_c[lt]z* return [0, prec-1], except when the
1051 // argument is 0, but that is undefined behavior.
1053 // For __builtin_c[lt]z* consider argument of 0 always undefined
1054 // behavior, for internal fns depending on C?Z_DEFINED_VALUE_AT_ZERO.
1055 arg = gimple_call_arg (call, 0);
1056 prec = TYPE_PRECISION (TREE_TYPE (arg));
1057 mini = 0;
1058 maxi = prec - 1;
1059 mode = SCALAR_INT_TYPE_MODE (TREE_TYPE (arg));
1060 if (gimple_call_internal_p (call))
1062 if (optab_handler (clz_optab, mode) != CODE_FOR_nothing
1063 && CLZ_DEFINED_VALUE_AT_ZERO (mode, zerov) == 2)
1065 // Only handle the single common value.
1066 if (zerov == prec)
1067 maxi = prec;
1068 else
1069 // Magic value to give up, unless we can prove arg is non-zero.
1070 mini = -2;
1074 src.get_operand (r, arg);
1075 // From clz of minimum we can compute result maximum.
1076 if (!r.undefined_p ())
1078 // From clz of minimum we can compute result maximum.
1079 if (wi::gt_p (r.lower_bound (), 0, TYPE_SIGN (r.type ())))
1081 maxi = prec - 1 - wi::floor_log2 (r.lower_bound ());
1082 if (mini == -2)
1083 mini = 0;
1085 else if (!range_includes_zero_p (&r))
1087 mini = 0;
1088 maxi = prec - 1;
1090 if (mini == -2)
1091 break;
1092 // From clz of maximum we can compute result minimum.
1093 wide_int max = r.upper_bound ();
1094 int newmini = prec - 1 - wi::floor_log2 (max);
1095 if (max == 0)
1097 // If CLZ_DEFINED_VALUE_AT_ZERO is 2 with VALUE of prec,
1098 // return [prec, prec], otherwise ignore the range.
1099 if (maxi == prec)
1100 mini = prec;
1102 else
1103 mini = newmini;
1105 if (mini == -2)
1106 break;
1107 r.set (build_int_cst (type, mini), build_int_cst (type, maxi));
1108 return true;
1110 CASE_CFN_CTZ:
1111 // __builtin_ctz* return [0, prec-1], except for when the
1112 // argument is 0, but that is undefined behavior.
1114 // For __builtin_ctz* consider argument of 0 always undefined
1115 // behavior, for internal fns depending on CTZ_DEFINED_VALUE_AT_ZERO.
1116 arg = gimple_call_arg (call, 0);
1117 prec = TYPE_PRECISION (TREE_TYPE (arg));
1118 mini = 0;
1119 maxi = prec - 1;
1120 mode = SCALAR_INT_TYPE_MODE (TREE_TYPE (arg));
1121 if (gimple_call_internal_p (call))
1123 if (optab_handler (ctz_optab, mode) != CODE_FOR_nothing
1124 && CTZ_DEFINED_VALUE_AT_ZERO (mode, zerov) == 2)
1126 // Handle only the two common values.
1127 if (zerov == -1)
1128 mini = -1;
1129 else if (zerov == prec)
1130 maxi = prec;
1131 else
1132 // Magic value to give up, unless we can prove arg is non-zero.
1133 mini = -2;
1136 src.get_operand (r, arg);
1137 if (!r.undefined_p ())
1139 // If arg is non-zero, then use [0, prec - 1].
1140 if (!range_includes_zero_p (&r))
1142 mini = 0;
1143 maxi = prec - 1;
1145 // If some high bits are known to be zero, we can decrease
1146 // the maximum.
1147 wide_int max = r.upper_bound ();
1148 if (max == 0)
1150 // Argument is [0, 0]. If CTZ_DEFINED_VALUE_AT_ZERO
1151 // is 2 with value -1 or prec, return [-1, -1] or [prec, prec].
1152 // Otherwise ignore the range.
1153 if (mini == -1)
1154 maxi = -1;
1155 else if (maxi == prec)
1156 mini = prec;
1158 // If value at zero is prec and 0 is in the range, we can't lower
1159 // the upper bound. We could create two separate ranges though,
1160 // [0,floor_log2(max)][prec,prec] though.
1161 else if (maxi != prec)
1162 maxi = wi::floor_log2 (max);
1164 if (mini == -2)
1165 break;
1166 r.set (build_int_cst (type, mini), build_int_cst (type, maxi));
1167 return true;
1169 CASE_CFN_CLRSB:
1170 arg = gimple_call_arg (call, 0);
1171 prec = TYPE_PRECISION (TREE_TYPE (arg));
1172 r.set (build_int_cst (type, 0), build_int_cst (type, prec - 1));
1173 return true;
1174 case CFN_UBSAN_CHECK_ADD:
1175 range_of_builtin_ubsan_call (r, call, PLUS_EXPR, src);
1176 return true;
1177 case CFN_UBSAN_CHECK_SUB:
1178 range_of_builtin_ubsan_call (r, call, MINUS_EXPR, src);
1179 return true;
1180 case CFN_UBSAN_CHECK_MUL:
1181 range_of_builtin_ubsan_call (r, call, MULT_EXPR, src);
1182 return true;
1184 case CFN_GOACC_DIM_SIZE:
1185 case CFN_GOACC_DIM_POS:
1186 // Optimizing these two internal functions helps the loop
1187 // optimizer eliminate outer comparisons. Size is [1,N]
1188 // and pos is [0,N-1].
1190 bool is_pos = func == CFN_GOACC_DIM_POS;
1191 int axis = oacc_get_ifn_dim_arg (call);
1192 int size = oacc_get_fn_dim_size (current_function_decl, axis);
1193 if (!size)
1194 // If it's dynamic, the backend might know a hardware limitation.
1195 size = targetm.goacc.dim_limit (axis);
1197 r.set (build_int_cst (type, is_pos ? 0 : 1),
1198 size
1199 ? build_int_cst (type, size - is_pos) : vrp_val_max (type));
1200 return true;
1203 case CFN_BUILT_IN_STRLEN:
1204 if (tree lhs = gimple_call_lhs (call))
1205 if (ptrdiff_type_node
1206 && (TYPE_PRECISION (ptrdiff_type_node)
1207 == TYPE_PRECISION (TREE_TYPE (lhs))))
1209 tree type = TREE_TYPE (lhs);
1210 tree max = vrp_val_max (ptrdiff_type_node);
1211 wide_int wmax
1212 = wi::to_wide (max, TYPE_PRECISION (TREE_TYPE (max)));
1213 tree range_min = build_zero_cst (type);
1214 // To account for the terminating NULL, the maximum length
1215 // is one less than the maximum array size, which in turn
1216 // is one less than PTRDIFF_MAX (or SIZE_MAX where it's
1217 // smaller than the former type).
1218 // FIXME: Use max_object_size() - 1 here.
1219 tree range_max = wide_int_to_tree (type, wmax - 2);
1220 r.set (range_min, range_max);
1221 return true;
1223 break;
1224 default:
1225 break;
1227 return false;
1231 // Calculate a range for COND_EXPR statement S and return it in R.
1232 // If a range cannot be calculated, return false.
1234 bool
1235 fold_using_range::range_of_cond_expr (irange &r, gassign *s, fur_source &src)
1237 int_range_max cond_range, range1, range2;
1238 tree cond = gimple_assign_rhs1 (s);
1239 tree op1 = gimple_assign_rhs2 (s);
1240 tree op2 = gimple_assign_rhs3 (s);
1242 tree type = gimple_range_type (s);
1243 if (!type)
1244 return false;
1246 gcc_checking_assert (gimple_assign_rhs_code (s) == COND_EXPR);
1247 gcc_checking_assert (range_compatible_p (TREE_TYPE (op1), TREE_TYPE (op2)));
1248 src.get_operand (cond_range, cond);
1249 src.get_operand (range1, op1);
1250 src.get_operand (range2, op2);
1252 // If the condition is known, choose the appropriate expression.
1253 if (cond_range.singleton_p ())
1255 // False, pick second operand.
1256 if (cond_range.zero_p ())
1257 r = range2;
1258 else
1259 r = range1;
1261 else
1263 r = range1;
1264 r.union_ (range2);
1266 gcc_checking_assert (r.undefined_p ()
1267 || range_compatible_p (r.type (), type));
1268 return true;
1271 // If SCEV has any information about phi node NAME, return it as a range in R.
1273 void
1274 fold_using_range::range_of_ssa_name_with_loop_info (irange &r, tree name,
1275 class loop *l, gphi *phi,
1276 fur_source &src)
1278 gcc_checking_assert (TREE_CODE (name) == SSA_NAME);
1279 tree min, max, type = TREE_TYPE (name);
1280 if (bounds_of_var_in_loop (&min, &max, src.query (), l, phi, name))
1282 if (TREE_CODE (min) != INTEGER_CST)
1284 if (src.query ()->range_of_expr (r, min, phi) && !r.undefined_p ())
1285 min = wide_int_to_tree (type, r.lower_bound ());
1286 else
1287 min = vrp_val_min (type);
1289 if (TREE_CODE (max) != INTEGER_CST)
1291 if (src.query ()->range_of_expr (r, max, phi) && !r.undefined_p ())
1292 max = wide_int_to_tree (type, r.upper_bound ());
1293 else
1294 max = vrp_val_max (type);
1296 r.set (min, max);
1298 else
1299 r.set_varying (type);
1302 // -----------------------------------------------------------------------
1304 // Check if an && or || expression can be folded based on relations. ie
1305 // c_2 = a_6 > b_7
1306 // c_3 = a_6 < b_7
1307 // c_4 = c_2 && c_3
1308 // c_2 and c_3 can never be true at the same time,
1309 // Therefore c_4 can always resolve to false based purely on the relations.
1311 void
1312 fold_using_range::relation_fold_and_or (irange& lhs_range, gimple *s,
1313 fur_source &src)
1315 // No queries or already folded.
1316 if (!src.gori () || !src.query ()->oracle () || lhs_range.singleton_p ())
1317 return;
1319 // Only care about AND and OR expressions.
1320 enum tree_code code = gimple_expr_code (s);
1321 bool is_and = false;
1322 if (code == BIT_AND_EXPR || code == TRUTH_AND_EXPR)
1323 is_and = true;
1324 else if (code != BIT_IOR_EXPR && code != TRUTH_OR_EXPR)
1325 return;
1327 tree lhs = gimple_get_lhs (s);
1328 tree ssa1 = gimple_range_ssa_p (gimple_range_operand1 (s));
1329 tree ssa2 = gimple_range_ssa_p (gimple_range_operand2 (s));
1331 // Deal with || and && only when there is a full set of symbolics.
1332 if (!lhs || !ssa1 || !ssa2
1333 || (TREE_CODE (TREE_TYPE (lhs)) != BOOLEAN_TYPE)
1334 || (TREE_CODE (TREE_TYPE (ssa1)) != BOOLEAN_TYPE)
1335 || (TREE_CODE (TREE_TYPE (ssa2)) != BOOLEAN_TYPE))
1336 return;
1338 // Now we know its a boolean AND or OR expression with boolean operands.
1339 // Ideally we search dependencies for common names, and see what pops out.
1340 // until then, simply try to resolve direct dependencies.
1342 // Both names will need to have 2 direct dependencies.
1343 tree ssa1_dep2 = src.gori ()->depend2 (ssa1);
1344 tree ssa2_dep2 = src.gori ()->depend2 (ssa2);
1345 if (!ssa1_dep2 || !ssa2_dep2)
1346 return;
1348 tree ssa1_dep1 = src.gori ()->depend1 (ssa1);
1349 tree ssa2_dep1 = src.gori ()->depend1 (ssa2);
1350 // Make sure they are the same dependencies, and detect the order of the
1351 // relationship.
1352 bool reverse_op2 = true;
1353 if (ssa1_dep1 == ssa2_dep1 && ssa1_dep2 == ssa2_dep2)
1354 reverse_op2 = false;
1355 else if (ssa1_dep1 != ssa2_dep2 || ssa1_dep2 != ssa2_dep1)
1356 return;
1358 range_operator *handler1 = gimple_range_handler (SSA_NAME_DEF_STMT (ssa1));
1359 range_operator *handler2 = gimple_range_handler (SSA_NAME_DEF_STMT (ssa2));
1361 // If either handler is not present, no relation is found.
1362 if (!handler1 || !handler2)
1363 return;
1365 int_range<2> bool_one (boolean_true_node, boolean_true_node);
1367 relation_kind relation1 = handler1->op1_op2_relation (bool_one);
1368 relation_kind relation2 = handler2->op1_op2_relation (bool_one);
1369 if (relation1 == VREL_NONE || relation2 == VREL_NONE)
1370 return;
1372 if (reverse_op2)
1373 relation2 = relation_negate (relation2);
1375 // x && y is false if the relation intersection of the true cases is NULL.
1376 if (is_and && relation_intersect (relation1, relation2) == VREL_EMPTY)
1377 lhs_range = int_range<2> (boolean_false_node, boolean_false_node);
1378 // x || y is true if the union of the true cases is NO-RELATION..
1379 // ie, one or the other being true covers the full range of possibilties.
1380 else if (!is_and && relation_union (relation1, relation2) == VREL_NONE)
1381 lhs_range = bool_one;
1382 else
1383 return;
1385 range_cast (lhs_range, TREE_TYPE (lhs));
1386 if (dump_file && (dump_flags & TDF_DETAILS))
1388 fprintf (dump_file, " Relation adjustment: ");
1389 print_generic_expr (dump_file, ssa1, TDF_SLIM);
1390 fprintf (dump_file, " and ");
1391 print_generic_expr (dump_file, ssa2, TDF_SLIM);
1392 fprintf (dump_file, " combine to produce ");
1393 lhs_range.dump (dump_file);
1394 fputc ('\n', dump_file);
1397 return;
1400 // Register any outgoing edge relations from a conditional branch.
1402 void
1403 fur_source::register_outgoing_edges (gcond *s, irange &lhs_range, edge e0, edge e1)
1405 int_range_max r;
1406 int_range<2> e0_range, e1_range;
1407 tree name;
1408 range_operator *handler;
1409 basic_block bb = gimple_bb (s);
1411 if (e0)
1413 // If this edge is never taken, ignore it.
1414 gcond_edge_range (e0_range, e0);
1415 e0_range.intersect (lhs_range);
1416 if (e0_range.undefined_p ())
1417 e0 = NULL;
1421 if (e1)
1423 // If this edge is never taken, ignore it.
1424 gcond_edge_range (e1_range, e1);
1425 e1_range.intersect (lhs_range);
1426 if (e1_range.undefined_p ())
1427 e1 = NULL;
1430 if (!e0 && !e1)
1431 return;
1433 // First, register the gcond itself. This will catch statements like
1434 // if (a_2 < b_5)
1435 tree ssa1 = gimple_range_ssa_p (gimple_range_operand1 (s));
1436 tree ssa2 = gimple_range_ssa_p (gimple_range_operand2 (s));
1437 if (ssa1 && ssa2)
1439 handler = gimple_range_handler (s);
1440 gcc_checking_assert (handler);
1441 if (e0)
1443 relation_kind relation = handler->op1_op2_relation (e0_range);
1444 if (relation != VREL_NONE)
1445 register_relation (e0, relation, ssa1, ssa2);
1447 if (e1)
1449 relation_kind relation = handler->op1_op2_relation (e1_range);
1450 if (relation != VREL_NONE)
1451 register_relation (e1, relation, ssa1, ssa2);
1455 // Outgoing relations of GORI exports require a gori engine.
1456 if (!gori ())
1457 return;
1459 // Now look for other relations in the exports. This will find stmts
1460 // leading to the condition such as:
1461 // c_2 = a_4 < b_7
1462 // if (c_2)
1463 FOR_EACH_GORI_EXPORT_NAME (*(gori ()), bb, name)
1465 if (TREE_CODE (TREE_TYPE (name)) != BOOLEAN_TYPE)
1466 continue;
1467 gimple *stmt = SSA_NAME_DEF_STMT (name);
1468 handler = gimple_range_handler (stmt);
1469 if (!handler)
1470 continue;
1471 tree ssa1 = gimple_range_ssa_p (gimple_range_operand1 (stmt));
1472 tree ssa2 = gimple_range_ssa_p (gimple_range_operand2 (stmt));
1473 if (ssa1 && ssa2)
1475 if (e0 && gori ()->outgoing_edge_range_p (r, e0, name, *m_query)
1476 && r.singleton_p ())
1478 relation_kind relation = handler->op1_op2_relation (r);
1479 if (relation != VREL_NONE)
1480 register_relation (e0, relation, ssa1, ssa2);
1482 if (e1 && gori ()->outgoing_edge_range_p (r, e1, name, *m_query)
1483 && r.singleton_p ())
1485 relation_kind relation = handler->op1_op2_relation (r);
1486 if (relation != VREL_NONE)
1487 register_relation (e1, relation, ssa1, ssa2);