Hi,
I found a few more cases that still cause internal compiler errors, I
managed to fix them. I have attached an updated patch.
Sean
On Tue, Mar 17, 2009 at 12:45 PM, Fu, Chao-Ying <[email protected]> wrote:
> Sean D'Epagnier wrote:
>>
>> I think I found a generic problem for fixed point constant folding.
>>
>> In fold-const.c:11872 gcc tries to apply:
>> /* Transform (x >> c) << c into x & (-1<<c), or transform (x <<
>> c) >> c
>> into x & ((unsigned)-1 >> c) for unsigned types. */
>>
>> I attached a simple patch which fixes the problem by not applying this
>> optimization to fixed point types. I would like to have this
>> optimization because it is possible.. but the problem is fixed-point
>> types do not support bitwise operations like & | ^ ~.. so without
>> supporting these somehow internally but not allowing the user to have
>> them, this can't take place.
>>
>> I am open to other suggestions. For future reference should this be
>> posted as a bug report? It seems simple enough that it could be
>> included right away.. but I feel like if it's a bug report no one will
>> notice since fixed-point support is not widely used.
>>
>> Sean
>>
>
> Thanks for finding this bug and fixing it! I think you should send your
> patch to [email protected], and check in this patch to mainline and 4.3
> if possible.
>
> Regards,
> Chao-ying
>
Index: fold-const.c
===================================================================
--- fold-const.c (revision 144210)
+++ fold-const.c (working copy)
@@ -11844,6 +11844,11 @@ fold_binary (enum tree_code code, tree t
if (TREE_CODE (arg1) == INTEGER_CST && tree_int_cst_sgn (arg1) < 0)
return NULL_TREE;
+ /* Since fixed point types cannot perform bitwise and, or, etc..
+ don't try to convert to an expression with them. */
+ if (TREE_CODE(type) == FIXED_POINT_TYPE)
+ return NULL_TREE;
+
/* Turn (a OP c1) OP c2 into a OP (c1+c2). */
if (TREE_CODE (op0) == code && host_integerp (arg1, false)
&& TREE_INT_CST_LOW (arg1) < TYPE_PRECISION (type)
Index: cse.c
===================================================================
--- cse.c (revision 144210)
+++ cse.c (working copy)
@@ -3509,9 +3509,10 @@ fold_rtx (rtx x, rtx insn)
&& exact_log2 (- INTVAL (const_arg1)) >= 0)))
break;
- /* ??? Vector mode shifts by scalar
+ /* ??? Vector and Fixed Point shifts by scalar
shift operand are not supported yet. */
- if (is_shift && VECTOR_MODE_P (mode))
+ if (is_shift && (VECTOR_MODE_P (mode)
+ || ALL_FIXED_POINT_MODE_P (mode)))
break;
if (is_shift