tree.c (truth_type_for): New function.
authorMarc Glisse <marc.glisse@inria.fr>
Sat, 29 Sep 2012 08:23:23 +0000 (10:23 +0200)
committerMarc Glisse <glisse@gcc.gnu.org>
Sat, 29 Sep 2012 08:23:23 +0000 (08:23 +0000)
2012-09-29  Marc Glisse  <marc.glisse@inria.fr>

* tree.c (truth_type_for): New function.
* tree.h (truth_type_for): Declare.
* gimple-fold.c (and_comparisons_1): Call it.
(or_comparisons_1): Likewise.
* tree-ssa-forwprop.c (forward_propagate_into_cond): Don't use
boolean_type_node for vectors.

From-SVN: r191848

gcc/ChangeLog
gcc/gimple-fold.c
gcc/tree-ssa-forwprop.c
gcc/tree.c
gcc/tree.h

index 78c31bca6f40c450c4304bcde0250eb1397d0436..e6a2cdbe28724c0afeb7ac22720f00c895bdc933 100644 (file)
@@ -1,3 +1,12 @@
+2012-09-29  Marc Glisse  <marc.glisse@inria.fr>
+
+       * tree.c (truth_type_for): New function.
+       * tree.h (truth_type_for): Declare.
+       * gimple-fold.c (and_comparisons_1): Call it.
+       (or_comparisons_1): Likewise.
+       * tree-ssa-forwprop.c (forward_propagate_into_cond): Don't use
+       boolean_type_node for vectors.
+
 2012-09-28  Jan Hubicka  <jh@suse.cz>
 
        * basic-block.h (RDIV): Define.
index 4dba726f274af966345af20833733148502a6261..66d076664cc3cadda3d2a7b67af77840c44733f5 100644 (file)
@@ -30,7 +30,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-ssa-propagate.h"
 #include "target.h"
 #include "gimple-fold.h"
-#include "langhooks.h"
 
 /* Return true when DECL can be referenced from current unit.
    FROM_DECL (if non-null) specify constructor of variable DECL was taken from.
@@ -1693,15 +1692,7 @@ static tree
 and_comparisons_1 (enum tree_code code1, tree op1a, tree op1b,
                   enum tree_code code2, tree op2a, tree op2b)
 {
-  tree truth_type = boolean_type_node;
-  if (TREE_CODE (TREE_TYPE (op1a)) == VECTOR_TYPE)
-    {
-      tree vec_type = TREE_TYPE (op1a);
-      tree elem = lang_hooks.types.type_for_size
-       (GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (vec_type))), 0);
-      truth_type = build_opaque_vector_type (elem,
-                                            TYPE_VECTOR_SUBPARTS (vec_type));
-    }
+  tree truth_type = truth_type_for (TREE_TYPE (op1a));
 
   /* First check for ((x CODE1 y) AND (x CODE2 y)).  */
   if (operand_equal_p (op1a, op2a, 0)
@@ -2165,15 +2156,7 @@ static tree
 or_comparisons_1 (enum tree_code code1, tree op1a, tree op1b,
                  enum tree_code code2, tree op2a, tree op2b)
 {
-  tree truth_type = boolean_type_node;
-  if (TREE_CODE (TREE_TYPE (op1a)) == VECTOR_TYPE)
-    {
-      tree vec_type = TREE_TYPE (op1a);
-      tree elem = lang_hooks.types.type_for_size
-       (GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (vec_type))), 0);
-      truth_type = build_opaque_vector_type (elem,
-                                            TYPE_VECTOR_SUBPARTS (vec_type));
-    }
+  tree truth_type = truth_type_for (TREE_TYPE (op1a));
 
   /* First check for ((x CODE1 y) OR (x CODE2 y)).  */
   if (operand_equal_p (op1a, op2a, 0)
index cd8f092915b9bf79af2c9d7e65f86a05b5c9a6c7..b0e951a22f774d2391f2897f0b7e1f25dcbd7e7b 100644 (file)
@@ -556,7 +556,7 @@ forward_propagate_into_cond (gimple_stmt_iterator *gsi_p)
   /* We can do tree combining on SSA_NAME and comparison expressions.  */
   if (COMPARISON_CLASS_P (cond))
     tmp = forward_propagate_into_comparison_1 (stmt, TREE_CODE (cond),
-                                              boolean_type_node,
+                                              TREE_TYPE (cond),
                                               TREE_OPERAND (cond, 0),
                                               TREE_OPERAND (cond, 1));
   else if (TREE_CODE (cond) == SSA_NAME)
index 9169424a01b14b90088e491d69e831d130f1f9e3..7f620e511be16bbc9161db27e451ff64fe14fd1b 100644 (file)
@@ -10250,6 +10250,22 @@ signed_type_for (tree type)
   return signed_or_unsigned_type_for (0, type);
 }
 
+/* If TYPE is a vector type, return a signed integer vector type with the
+   same width and number of subparts. Otherwise return boolean_type_node.  */
+
+tree
+truth_type_for (tree type)
+{
+  if (TREE_CODE (type) == VECTOR_TYPE)
+    {
+      tree elem = lang_hooks.types.type_for_size
+        (GET_MODE_BITSIZE (TYPE_MODE (TREE_TYPE (type))), 0);
+      return build_opaque_vector_type (elem, TYPE_VECTOR_SUBPARTS (type));
+    }
+  else
+    return boolean_type_node;
+}
+
 /* Returns the largest value obtainable by casting something in INNER type to
    OUTER type.  */
 
index 2050efd71e1df812e0dba37582d46af4f6d88b24..0130ce464ee382dbe3d9891d5d5f7c976807e6e4 100644 (file)
@@ -4769,6 +4769,7 @@ extern tree make_unsigned_type (int);
 extern tree signed_or_unsigned_type_for (int, tree);
 extern tree signed_type_for (tree);
 extern tree unsigned_type_for (tree);
+extern tree truth_type_for (tree);
 extern void initialize_sizetypes (void);
 extern void fixup_unsigned_type (tree);
 extern tree build_pointer_type_for_mode (tree, enum machine_mode, bool);