public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-2514] Implement operator_bitwise_xor::op1_op2_relation_effect.
@ 2021-07-26 14:49 Aldy Hernandez
  0 siblings, 0 replies; only message in thread
From: Aldy Hernandez @ 2021-07-26 14:49 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:f384e2f551fef6dd73b815675633814fb8ff1e13

commit r12-2514-gf384e2f551fef6dd73b815675633814fb8ff1e13
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Mon Jul 26 06:08:24 2021 -0500

    Implement operator_bitwise_xor::op1_op2_relation_effect.
    
    This patch adjusts XORing of ranges where the operands are known to be
    equal or not equal.
    
    We should probably do the same thing for the op[12]_range methods.
    
    gcc/ChangeLog:
    
            * range-op.cc (operator_bitwise_xor::op1_op2_relation_effect):
            New.

Diff:
---
 gcc/range-op.cc | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index 4bdd14dd6f7..b1fb25c77f8 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -3101,6 +3101,11 @@ public:
 			  const irange &lhs,
 			  const irange &op1,
 			  relation_kind rel = VREL_NONE) const;
+  virtual bool op1_op2_relation_effect (irange &lhs_range,
+					tree type,
+					const irange &op1_range,
+					const irange &op2_range,
+					relation_kind rel) const;
 } op_bitwise_xor;
 
 void
@@ -3134,6 +3139,34 @@ operator_bitwise_xor::wi_fold (irange &r, tree type,
     r.set_varying (type);
 }
 
+bool
+operator_bitwise_xor::op1_op2_relation_effect (irange &lhs_range,
+					       tree type,
+					       const irange &,
+					       const irange &,
+					       relation_kind rel) const
+{
+  if (rel == VREL_NONE)
+    return false;
+
+  int_range<2> rel_range;
+
+  switch (rel)
+    {
+    case EQ_EXPR:
+      rel_range.set_zero (type);
+      break;
+    case NE_EXPR:
+      rel_range.set_nonzero (type);
+      break;
+    default:
+      return false;
+    }
+
+  lhs_range.intersect (rel_range);
+  return true;
+}
+
 bool
 operator_bitwise_xor::op1_range (irange &r, tree type,
 				 const irange &lhs,


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-26 14:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-26 14:49 [gcc r12-2514] Implement operator_bitwise_xor::op1_op2_relation_effect Aldy Hernandez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).