This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Is this a bug in the folder?
- From: Diego Novillo <dnovillo at redhat dot com>
- To: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Cc: Roger Sayle <roger at eyesopen dot com>, Richard Henderson <rth at redhat dot com>
- Date: Tue, 21 Sep 2004 11:29:52 -0400
- Subject: Is this a bug in the folder?
- Organization: Red Hat Canada
With a local patch, I am triggering an ice in NUMERICAL_TYPE_CHECK
because it is trying to get the lower bound on a VECTOR_TYPE.
/* If we are widening one operand of an integer comparison,
see if the other operand is similarly being widened. Perhaps we
can do the comparison in the narrower type. */
else if (TREE_CODE (TREE_TYPE (arg0)) == INTEGER_TYPE
&& TREE_CODE (arg0) == NOP_EXPR
&& (tem = get_unwidened (arg0, NULL_TREE)) != arg0
&& (code == EQ_EXPR || code == NE_EXPR
|| TYPE_UNSIGNED (TREE_TYPE (arg0))
== TYPE_UNSIGNED (TREE_TYPE (tem)))
&& (t1 = get_unwidened (arg1, TREE_TYPE (tem))) != 0
&& (TREE_TYPE (t1) == TREE_TYPE (tem)
|| (TREE_CODE (t1) == INTEGER_CST
&& int_fits_type_p (t1, TREE_TYPE (tem)))))
The failure occurs when we try to fold the following expression
(testsuite/gcc.dg/20020531-1.c):
(long long unsigned int) D.1201 != 1122334455667788
The type of D.1201 is
<vector_type 0xf6f8a32c
type <integer_type 0xf6fda244 signed char public QI
size <integer_cst 0xf6fd71c8 constant invariant 8>
unit size <integer_cst 0xf6fd71e0 constant invariant 1>
align 8 symtab 0 alias set -1 precision 8 min <integer_cst 0xf6fd7198 -128> max <integer_cst 0xf6fd71b0 127>
pointer_to_this <pointer_type 0xf6f890e8>>
V8QI
size <integer_cst 0xf6fd75e8 type <integer_type 0xf6fda1d0 bit_size_type> constant invariant 64>
unit size <integer_cst 0xf6fd7600 type <integer_type 0xf6fda15c unsigned int> constant invariant 8>
align 64 symtab 0 alias set -1 nunits 8>
The code fragment I quoted from fold-const.c has
arg0 -> (long long unsigned int)D.1201
tem -> D.1201
So, when we call int_fits_type_p() we are passing a VECTOR_TYPE to it,
which triggers the ICE.
You can trigger this by compiling testsuite/gcc.dg/20020531-1.c after
applying this patchlet to tree-cfg.c:
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-cfg.c,v
retrieving revision 2.55
diff -d -u -p -r2.55 tree-cfg.c
--- tree-cfg.c 17 Sep 2004 21:54:37 -0000 2.55
+++ tree-cfg.c 21 Sep 2004 15:28:32 -0000
@@ -2003,20 +2002,8 @@ find_taken_edge (basic_block bb, tree va
/* If VAL is a predicate of the form N RELOP N, where N is an
SSA_NAME, we can always determine its truth value (except when
doing floating point comparisons that may involve NaNs). */
- if (val
- && COMPARISON_CLASS_P (val)
- && TREE_OPERAND (val, 0) == TREE_OPERAND (val, 1)
- && TREE_CODE (TREE_OPERAND (val, 0)) == SSA_NAME
- && (TREE_CODE (TREE_TYPE (TREE_OPERAND (val, 0))) != REAL_TYPE
- || !HONOR_NANS (TYPE_MODE (TREE_TYPE (TREE_OPERAND (val, 0))))))
- {
- enum tree_code code = TREE_CODE (val);
-
- if (code == EQ_EXPR || code == LE_EXPR || code == GE_EXPR)
- val = boolean_true_node;
- else if (code == LT_EXPR || code == GT_EXPR || code == NE_EXPR)
- val = boolean_false_node;
- }
+ if (val && COMPARISON_CLASS_P (val))
+ val = fold (val);
/* If VAL is not a constant, we can't determine which edge might
be taken. */
Any ideas?
Thanks. Diego.