]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
generic-match-head.c (types_match): Handle non-types.
authorMarc Glisse <marc.glisse@inria.fr>
Thu, 14 May 2015 14:45:33 +0000 (16:45 +0200)
committerMarc Glisse <glisse@gcc.gnu.org>
Thu, 14 May 2015 14:45:33 +0000 (14:45 +0000)
2015-05-14  Marc Glisse  <marc.glisse@inria.fr>

gcc/
* generic-match-head.c (types_match): Handle non-types.
* gimple-match-head.c (types_match): Likewise.
* match.pd: Remove unnecessary TREE_TYPE for types_match.

From-SVN: r223199

gcc/ChangeLog
gcc/generic-match-head.c
gcc/gimple-match-head.c
gcc/match.pd

index ba35c777c7f2251bc4ebe7427698a586de92d6c0..f41771ee24b01b776a698be226cfce1b08b9a424 100644 (file)
@@ -1,3 +1,9 @@
+2015-05-14  Marc Glisse  <marc.glisse@inria.fr>
+
+       * generic-match-head.c (types_match): Handle non-types.
+       * gimple-match-head.c (types_match): Likewise.
+       * match.pd: Remove unnecessary TREE_TYPE for types_match.
+
 2015-05-14  Wilco Dijkstra  <wdijkstr@arm.com>
 
        * config/aarch64/aarch64.md (absdi2): Optimize abs expansion.
index efaa2d8b7ce48608fdb941064d085c8e99142617..40dc53f5bf8e05774d4b32ab13cd002f395fd207 100644 (file)
@@ -71,11 +71,17 @@ along with GCC; see the file COPYING3.  If not see
 #include "generic-match.h"
 
 /* Routine to determine if the types T1 and T2 are effectively
-   the same for GENERIC.  */
+   the same for GENERIC.  If T1 or T2 is not a type, the test
+   applies to their TREE_TYPE.  */
 
 static inline bool
 types_match (tree t1, tree t2)
 {
+  if (!TYPE_P (t1))
+    t1 = TREE_TYPE (t1);
+  if (!TYPE_P (t2))
+    t2 = TREE_TYPE (t2);
+
   return TYPE_MAIN_VARIANT (t1) == TYPE_MAIN_VARIANT (t2);
 }
 
index 7b9348b53ec014538ba457b89543c551059d962c..cac037b31df63cdfa80dc59c995ed1de4931f5c3 100644 (file)
@@ -862,11 +862,17 @@ do_valueize (tree (*valueize)(tree), tree op)
 }
 
 /* Routine to determine if the types T1 and T2 are effectively
-   the same for GIMPLE.  */
+   the same for GIMPLE.  If T1 or T2 is not a type, the test
+   applies to their TREE_TYPE.  */
 
 static inline bool
 types_match (tree t1, tree t2)
 {
+  if (!TYPE_P (t1))
+    t1 = TREE_TYPE (t1);
+  if (!TYPE_P (t2))
+    t2 = TREE_TYPE (t2);
+
   return types_compatible_p (t1, t2);
 }
 
index 51a950acaa960c49afb17db612856ca61f6926eb..fffe6946325dc421d6246a363dd0b6864b0e8c5a 100644 (file)
@@ -289,7 +289,7 @@ along with GCC; see the file COPYING3.  If not see
   (if (((TREE_CODE (@1) == INTEGER_CST
         && INTEGRAL_TYPE_P (TREE_TYPE (@0))
         && int_fits_type_p (@1, TREE_TYPE (@0)))
-       || types_match (TREE_TYPE (@0), TREE_TYPE (@1)))
+       || types_match (@0, @1))
        /* ???  This transform conflicts with fold-const.c doing
          Convert (T)(x & c) into (T)x & (T)c, if c is an integer
          constants (if x has signed type, the sign bit cannot be set
@@ -948,7 +948,7 @@ along with GCC; see the file COPYING3.  If not see
 /* Unordered tests if either argument is a NaN.  */
 (simplify
  (bit_ior (unordered @0 @0) (unordered @1 @1))
- (if (types_match (TREE_TYPE (@0), TREE_TYPE (@1)))
+ (if (types_match (@0, @1))
   (unordered @0 @1)))
 (simplify
  (bit_ior:c (unordered @0 @0) (unordered:c@2 @0 @1))
@@ -1068,8 +1068,8 @@ along with GCC; see the file COPYING3.  If not see
         && TYPE_PRECISION (type) == GET_MODE_PRECISION (TYPE_MODE (type))
         /* The inner conversion must be a widening conversion.  */
         && TYPE_PRECISION (TREE_TYPE (@2)) > TYPE_PRECISION (TREE_TYPE (@0))
-        && types_match (TREE_TYPE (@0), TREE_TYPE (@1))
-        && types_match (TREE_TYPE (@0), type)
+        && types_match (@0, @1)
+        && types_match (@0, type)
         && single_use (@4))
       (if (TYPE_OVERFLOW_WRAPS (TREE_TYPE (@0)))
        (convert (op @0 @1)))
@@ -1099,7 +1099,7 @@ along with GCC; see the file COPYING3.  If not see
         && TYPE_PRECISION (type) == GET_MODE_PRECISION (TYPE_MODE (type))
         /* The inner conversion must be a widening conversion.  */
         && TYPE_PRECISION (TREE_TYPE (@2)) > TYPE_PRECISION (TREE_TYPE (@0))
-        && types_match (TREE_TYPE (@0), TREE_TYPE (@1))
+        && types_match (@0, @1)
         && (tree_int_cst_min_precision (@4, UNSIGNED)
             <= TYPE_PRECISION (TREE_TYPE (@0)))
         && single_use (@5))