Hi,
On Thu, 13 Oct 2011, Kai Tietz wrote:
> this new version addresses the comments from Michael and additional fixes
> an latent issue shown up by this rewrite in fold-const.
> On gimplify.c's gimple_boolify we didn't handled the case that operands
> for TRUTH-expressions need to have same operand-size for transformation to
> bitwise operation.
The requirement comes from BIT_AND_EXPR, not from any of the TRUTH_*
expressions, hence the point of generating the BIT_AND_EXPR is the point
to fixup the types. Similar to this (fixes your testcase):
Index: gimplify.c
===================================================================
--- gimplify.c (revision 179855)
+++ gimplify.c (working copy)
/* See if any simplifications can be done based on what the RHS is. */
@@ -7257,6 +7264,18 @@ gimplify_expr (tree *expr_p, gimple_seq
{
tree orig_type = TREE_TYPE (*expr_p);
*expr_p = gimple_boolify (*expr_p);
+ /* We are going to transform this into BIT operations,
+ which have stricter requirements on the operand types. */
+ if (!useless_type_conversion_p
+ (orig_type, TREE_TYPE (TREE_OPERAND (*expr_p, 0))))
+ TREE_OPERAND (*expr_p, 0)
+ = fold_convert_loc (input_location, orig_type,
+ TREE_OPERAND (*expr_p, 0));
+ if (!useless_type_conversion_p
+ (orig_type, TREE_TYPE (TREE_OPERAND (*expr_p, 1))))
+ TREE_OPERAND (*expr_p, 1)
+ = fold_convert_loc (input_location, orig_type,
+ TREE_OPERAND (*expr_p, 1));
if (!useless_type_conversion_p (orig_type, TREE_TYPE (*expr_p)))
{
*expr_p = fold_convert_loc (input_location, orig_type, *expr_p);
Ciao,
Michael.