This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[tree-ssa] PATCH to simplify_cond_expr


Because C comparisons have integer type, they get assigned to integer
temps, and invert_truthvalue doesn't know that such temps have boolean
values, so it aborts.  Fixed by passing the condition through
truthvalue_conversion before inverting it.  Long term I want to give
comparisons BOOLEAN_TYPE in GIMPLE, but that has turned out to be tricky.

Fixes libmudflap.c/pass18-frag.c.

Tested athlon-pc-linux-gnu, applied to tree-ssa branch.

2003-06-03  Jason Merrill  <jason@redhat.com>

	* gimplify.c (simplify_cond_expr): Call truthvalue_conversion
	before invert_truthvalue.

*** gimplify.c.~1~	Mon Jun  2 13:09:26 2003
--- gimplify.c	Tue Jun  3 01:44:46 2003
*************** simplify_cond_expr (expr_p, pre_p, targe
*** 1701,1707 ****
    /* Rewrite "if (a); else b" to "if (!a) b"  */
    if (!TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 1)))
      {
!       TREE_OPERAND (expr, 0) = invert_truthvalue (TREE_OPERAND (expr, 0));
        tmp = TREE_OPERAND (expr, 1);
        TREE_OPERAND (expr, 1) = TREE_OPERAND (expr, 2);
        TREE_OPERAND (expr, 2) = tmp;
--- 1701,1708 ----
    /* Rewrite "if (a); else b" to "if (!a) b"  */
    if (!TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 1)))
      {
!       tree cond = (*lang_hooks.truthvalue_conversion) (TREE_OPERAND (expr, 0));
!       TREE_OPERAND (expr, 0) = invert_truthvalue (cond);
        tmp = TREE_OPERAND (expr, 1);
        TREE_OPERAND (expr, 1) = TREE_OPERAND (expr, 2);
        TREE_OPERAND (expr, 2) = tmp;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]