[COMMITTED 2/7] Add relational support to range-op.

Andrew MacLeod amacleod@redhat.com
Tue Jun 22 13:17:57 GMT 2021

THis patch adds relation support to range-ops.

a relation_kind is added to all fold and op1/2_range operations, which 
will allow any known relation to be applied during calculations.

4 more routines are provided which enable range-ops to indicate when a 
relation is caused by an expression/result and what effects it may have. 
    All relations are driven from these routines.

virtual enum tree_code lhs_op1_relation (const irange &lhs, const irange 
&op1, const irange &op2) const;
virtual enum tree_code lhs_op2_relation (const irange &lhs, const irange 
&op1, const irange &op2) const;
virtual enum tree_code op1_op2_relation (const irange &lhs) const;
virtual bool op1_op2_relation_effect (irange &lhs_range, tree type, 
const irange &op1_range, const irange &op2_range, relation_kind rel) const;

This initial patch provides the basic of the relation opcodes. Ie,  
operator_equal has added

enum tree_code
operator_equal::op1_op2_relation (const irange &lhs) const
   if (lhs.undefined_p ())
     return VREL_EMPTY;

   // FALSE = op1 == op2 indicates NE_EXPR.
   if (lhs.zero_p ())
     return NE_EXPR;

   // TRUE = op1 == op2 indicates EQ_EXPR.
   if (!lhs.contains_p (build_zero_cst (lhs.type ())))
     return EQ_EXPR;
   return VREL_NONE;

This teaches range-ops that there is a relation between op1 and op2 is 
the LHS has a range of FALSE, or TRUE.  Otherwise, we don't know what 
the relation is.

All 6 basic relations are implemented, as well as folding of these 
opcodes when a relation is to be applied.  Ie, how to fold it ( if a_2 
== b_2 is being folded., and the known relation coming into this 
expression is a_2 > b_2, it will fold to [0,0] or false.

Again, this patch on its own will not cause anything to actually happen, 
that will be enabled in the next patch. Virtually all relation 
generation and application is handled via these range-ops routines.

  Bootstraps on x86_64-pc-linux-gnu with no regressions.  Pushed.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Add-relational-support-to-range-op.patch
Type: text/x-patch
Size: 45050 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20210622/c7b31d03/attachment-0001.bin>

More information about the Gcc-patches mailing list