From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6258 invoked by alias); 8 Jul 2011 11:33:20 -0000 Received: (qmail 6247 invoked by uid 22791); 8 Jul 2011 11:33:17 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-qw0-f47.google.com (HELO mail-qw0-f47.google.com) (209.85.216.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 08 Jul 2011 11:33:00 +0000 Received: by qwh5 with SMTP id 5so1043222qwh.20 for ; Fri, 08 Jul 2011 04:32:59 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.86.135 with SMTP id s7mr1408418qcl.152.1310124779742; Fri, 08 Jul 2011 04:32:59 -0700 (PDT) Received: by 10.229.102.10 with HTTP; Fri, 8 Jul 2011 04:32:59 -0700 (PDT) In-Reply-To: References: Date: Fri, 08 Jul 2011 11:35:00 -0000 Message-ID: Subject: Re: [patch tree-optimization]: [2 of 3]: Boolify compares & more From: Kai Tietz To: Richard Guenther Cc: GCC Patches Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-07/txt/msg00622.txt.bz2 2011/7/8 Richard Guenther : > On Thu, Jul 7, 2011 at 6:07 PM, Kai Tietz wrote: >> Hello, >> >> This patch - second of series - adds boolification of comparisions in >> gimplifier. =A0For this >> casts from/to boolean are marked as not-useless. And in fold_unary_loc >> casts to non-boolean integral types are preserved. >> The hunk in tree-ssa-forwprop.c in combine_cond-expr_cond is not strictly >> necessary - as long as fold-const handles 1-bit precision bitwise-expres= sion >> with truth-logic - but it has shown to short-cut some expensier folding.= So >> I kept it within this patch. > > Please split it out. =A0Also ... > >> >> The adjusted testcase gcc.dg/uninit-15.c indicates that due >> optimization we loose >> in this case variables declaration. =A0But this might be to be expected. >> >> In vectorization we have a regression in gcc.dg/vect/vect-cond-3.c >> test-case. =A0It's caused >> by always having boolean-type on conditions. =A0So vectorizer sees >> different types, which >> aren't handled by vectorizer right now. =A0Maybe this issue could be >> special-cased for >> boolean-types in tree-vect-loop, by making operand for used condition >> equal to vector-type. >> But this is a subject for a different patch and not addressed by this se= ries. >> >> There is a regressions in tree-ssa/vrp47.c, and the fix is addressed >> by the 3rd patch of this >> series. >> >> Bootstrapped and regression tested for all standard-languages (plus >> Ada and Obj-C++) on host x86_64-pc-linux-gnu. >> >> Ok for apply? >> >> Regards, >> Kai >> >> >> ChangeLog >> >> 2011-07-07 =A0Kai Tietz =A0 >> >> =A0 =A0 =A0 =A0* fold-const.c (fold_unary_loc): Preserve >> =A0 =A0 =A0 =A0non-boolean-typed casts. >> =A0 =A0 =A0 =A0* gimplify.c (gimple_boolify): Handle boolification >> =A0 =A0 =A0 =A0of comparisons. >> =A0 =A0 =A0 =A0(gimplify_expr): Boolifiy non aggregate-typed >> =A0 =A0 =A0 =A0comparisons. >> =A0 =A0 =A0 =A0* tree-cfg.c (verify_gimple_comparison): Check result >> =A0 =A0 =A0 =A0type of comparison expression. >> =A0 =A0 =A0 =A0* tree-ssa.c (useless_type_conversion_p): Preserve incomp= atible >> =A0 =A0 =A0 =A0casts from/to boolean, >> =A0 =A0 =A0 =A0* tree-ssa-forwprop.c (combine_cond_expr_cond): Add simpl= ification >> =A0 =A0 =A0 =A0support for one-bit-precision typed X for cases X !=3D 0 = and X =3D=3D 0. >> =A0 =A0 =A0 =A0(forward_propagate_comparison): Adjust test of condition >> =A0 =A0 =A0 =A0result. >> >> >> =A0 =A0 =A0 =A0* gcc.dg/tree-ssa/builtin-expect-5.c: Adjusted. >> =A0 =A0 =A0 =A0* gcc.dg/tree-ssa/pr21031.c: Likewise. >> =A0 =A0 =A0 =A0* gcc.dg/tree-ssa/pr30978.c: Likewise. >> =A0 =A0 =A0 =A0* gcc.dg/tree-ssa/ssa-fre-6.c: Likewise. >> =A0 =A0 =A0 =A0* gcc.dg/binop-xor1.c: Mark it as expected fail. >> =A0 =A0 =A0 =A0* gcc.dg/binop-xor3.c: Likewise. >> =A0 =A0 =A0 =A0* gcc.dg/uninit-15.c: Adjust reported message. >> >> Index: gcc-head/gcc/fold-const.c >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >> --- gcc-head.orig/gcc/fold-const.c >> +++ gcc-head/gcc/fold-const.c >> @@ -7665,11 +7665,11 @@ fold_unary_loc (location_t loc, enum tre >> =A0 =A0 =A0 =A0 =A0 =A0 non-integral type. >> =A0 =A0 =A0 =A0 =A0 =A0 Do not fold the result as that would not simplif= y further, also >> =A0 =A0 =A0 =A0 =A0 =A0 folding again results in recursions. =A0*/ >> - =A0 =A0 =A0 =A0 if (INTEGRAL_TYPE_P (type)) >> + =A0 =A0 =A0 =A0 if (TREE_CODE (type) =3D=3D BOOLEAN_TYPE) >> =A0 =A0 =A0 =A0 =A0 =A0return build2_loc (loc, TREE_CODE (op0), type, >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 TREE_OPERAND= (op0, 0), >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 TREE_OPERAND= (op0, 1)); >> - =A0 =A0 =A0 =A0 else >> + =A0 =A0 =A0 =A0 else if (!INTEGRAL_TYPE_P (type)) >> =A0 =A0 =A0 =A0 =A0 =A0return build3_loc (loc, COND_EXPR, type, op0, >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 fold_convert= (type, boolean_true_node), >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 fold_convert= (type, boolean_false_node)); >> Index: gcc-head/gcc/gimplify.c >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >> --- gcc-head.orig/gcc/gimplify.c >> +++ gcc-head/gcc/gimplify.c >> @@ -2842,18 +2842,23 @@ gimple_boolify (tree expr) >> >> =A0 =A0 case TRUTH_NOT_EXPR: >> =A0 =A0 =A0 TREE_OPERAND (expr, 0) =3D gimple_boolify (TREE_OPERAND (exp= r, 0)); >> - =A0 =A0 =A0/* FALLTHRU */ >> >> - =A0 =A0case EQ_EXPR: case NE_EXPR: >> - =A0 =A0case LE_EXPR: case GE_EXPR: case LT_EXPR: case GT_EXPR: >> =A0 =A0 =A0 /* These expressions always produce boolean results. =A0*/ >> - =A0 =A0 =A0TREE_TYPE (expr) =3D boolean_type_node; >> + =A0 =A0 =A0if (TREE_CODE (type) !=3D BOOLEAN_TYPE) >> + =A0 =A0 =A0 TREE_TYPE (expr) =3D boolean_type_node; >> =A0 =A0 =A0 return expr; >> >> =A0 =A0 default: >> + =A0 =A0 =A0if (COMPARISON_CLASS_P (expr)) >> + =A0 =A0 =A0 { >> + =A0 =A0 =A0 =A0 /* There expressions always prduce boolean results. = =A0*/ >> + =A0 =A0 =A0 =A0 if (TREE_CODE (type) !=3D BOOLEAN_TYPE) >> + =A0 =A0 =A0 =A0 =A0 TREE_TYPE (expr) =3D boolean_type_node; >> + =A0 =A0 =A0 =A0 return expr; >> + =A0 =A0 =A0 } >> =A0 =A0 =A0 /* Other expressions that get here must have boolean values,= but >> =A0 =A0 =A0 =A0 might need to be converted to the appropriate mode. =A0*/ >> - =A0 =A0 =A0if (type =3D=3D boolean_type_node) >> + =A0 =A0 =A0if (TREE_CODE (type) =3D=3D BOOLEAN_TYPE) >> =A0 =A0 =A0 =A0return expr; >> =A0 =A0 =A0 return fold_convert_loc (loc, boolean_type_node, expr); >> =A0 =A0 } >> @@ -6763,7 +6768,7 @@ gimplify_expr (tree *expr_p, gimple_seq >> =A0 =A0 =A0 =A0 =A0 =A0tree org_type =3D TREE_TYPE (*expr_p); >> >> =A0 =A0 =A0 =A0 =A0 =A0*expr_p =3D gimple_boolify (*expr_p); >> - =A0 =A0 =A0 =A0 =A0 if (org_type !=3D boolean_type_node) >> + =A0 =A0 =A0 =A0 =A0 if (!useless_type_conversion_p (org_type, TREE_TYP= E (*expr_p))) >> =A0 =A0 =A0 =A0 =A0 =A0 =A0{ >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0*expr_p =3D fold_convert (org_type, *expr= _p); > > Use fold_convert_loc with saved_location Oh, good catch. Yes, I will adjust that. >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ret =3D GS_OK; >> @@ -7208,7 +7213,7 @@ gimplify_expr (tree *expr_p, gimple_seq >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 fold_truth_not_expr) happily uses operand ty= pe and doesn't >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 automatically uses boolean_type as result, w= e need to keep >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 orignal type. =A0*/ >> - =A0 =A0 =A0 =A0 =A0 if (org_type !=3D boolean_type_node) >> + =A0 =A0 =A0 =A0 =A0 if (!useless_type_conversion_p (org_type, TREE_TYP= E (*expr_p))) >> =A0 =A0 =A0 =A0 =A0 =A0 =A0{ >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0*expr_p =3D fold_convert (org_type, *expr= _p); > > Likewise. =A0Maybe this fixes the diagnostic regression. > >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ret =3D GS_OK; >> @@ -7288,7 +7293,19 @@ gimplify_expr (tree *expr_p, gimple_seq >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0tree type =3D TREE_TYPE (TREE_OPERAND= (*expr_p, 1)); >> >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (!AGGREGATE_TYPE_P (type)) >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto expr_2; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 tree org_type =3D TREE_TYPE (*= expr_p); >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 *expr_p =3D gimple_boolify (*e= xpr_p); >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (!useless_type_conversion_p= (org_type, >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 TREE_TYPE (*expr_p))) >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 *expr_p =3D fold_conve= rt_loc (saved_location, >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 org_type, *expr_p); >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ret =3D GS_OK; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 else >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto expr_2; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 } >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0else if (TYPE_MODE (type) !=3D BLKmod= e) >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ret =3D gimplify_scalar_mode_aggr= egate_compare (expr_p); >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0else >> Index: gcc-head/gcc/tree-cfg.c >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >> --- gcc-head.orig/gcc/tree-cfg.c >> +++ gcc-head/gcc/tree-cfg.c >> @@ -3203,7 +3203,9 @@ verify_gimple_comparison (tree type, tre >> =A0 =A0 =A0 =A0&& (!POINTER_TYPE_P (op0_type) >> =A0 =A0 =A0 =A0 =A0 || !POINTER_TYPE_P (op1_type) >> =A0 =A0 =A0 =A0 =A0 || TYPE_MODE (op0_type) !=3D TYPE_MODE (op1_type))) >> - =A0 =A0 =A0|| !INTEGRAL_TYPE_P (type)) >> + =A0 =A0 =A0|| !INTEGRAL_TYPE_P (type) >> + =A0 =A0 =A0|| (TREE_CODE (type) !=3D BOOLEAN_TYPE >> + =A0 =A0 =A0 =A0 && TYPE_PRECISION (type) !=3D 1)) >> =A0 =A0 { >> =A0 =A0 =A0 error ("type mismatch in comparison expression"); >> =A0 =A0 =A0 debug_generic_expr (type); >> Index: gcc-head/gcc/tree-ssa.c >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >> --- gcc-head.orig/gcc/tree-ssa.c >> +++ gcc-head/gcc/tree-ssa.c >> @@ -1306,10 +1306,10 @@ useless_type_conversion_p (tree outer_ty >> =A0 =A0 =A0 =A0 =A0|| TYPE_PRECISION (inner_type) !=3D TYPE_PRECISION (o= uter_type)) >> =A0 =A0 =A0 =A0return false; >> >> - =A0 =A0 =A0/* Preserve conversions to BOOLEAN_TYPE if it is not of pre= cision >> - =A0 =A0 =A0 =A0 one. =A0*/ >> - =A0 =A0 =A0if (TREE_CODE (inner_type) !=3D BOOLEAN_TYPE >> - =A0 =A0 =A0 =A0 && TREE_CODE (outer_type) =3D=3D BOOLEAN_TYPE >> + =A0 =A0 =A0/* Preserve conversions to/from BOOLEAN_TYPE if types are n= ot >> + =A0 =A0 =A0 =A0of precision one. =A0*/ >> + =A0 =A0 =A0if (((TREE_CODE (inner_type) =3D=3D BOOLEAN_TYPE) >> + =A0 =A0 =A0 =A0 =A0!=3D (TREE_CODE (outer_type) =3D=3D BOOLEAN_TYPE)) >> =A0 =A0 =A0 =A0 =A0&& TYPE_PRECISION (outer_type) !=3D 1) >> =A0 =A0 =A0 =A0return false; >> >> Index: gcc-head/gcc/testsuite/gcc.dg/tree-ssa/builtin-expect-5.c >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >> --- gcc-head.orig/gcc/testsuite/gcc.dg/tree-ssa/builtin-expect-5.c >> +++ gcc-head/gcc/testsuite/gcc.dg/tree-ssa/builtin-expect-5.c >> @@ -11,5 +11,5 @@ f (int i, float j) >> >> =A0/* { dg-final { scan-tree-dump-times { if } 2 "forwprop1"} } */ >> =A0/* { dg-final { scan-tree-dump {builtin_expect[^\n]*, 0\);\n[^\n]*if} >> "forwprop1"} } */ >> -/* { dg-final { scan-tree-dump {builtin_expect[^\n]*, 1\);\n[^\n]*if} >> "forwprop1"} } */ >> +/* { dg-final { scan-tree-dump-not {builtin_expect[^\n]*, >> 1\);\n[^\n]*if} "forwprop1"} } */ > > Hm? =A0Why that? > >> =A0/* { dg-final { cleanup-tree-dump "forwprop?" } } */ >> Index: gcc-head/gcc/testsuite/gcc.dg/tree-ssa/pr21031.c >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >> --- gcc-head.orig/gcc/testsuite/gcc.dg/tree-ssa/pr21031.c >> +++ gcc-head/gcc/testsuite/gcc.dg/tree-ssa/pr21031.c >> @@ -16,5 +16,5 @@ foo (int a) >> =A0 =A0 return 0; >> =A0} >> >> -/* { dg-final { scan-tree-dump-times "Replaced" 2 "forwprop1"} } */ >> +/* { dg-final { scan-tree-dump-times "Replaced" 1 "forwprop1"} } */ >> =A0/* { dg-final { cleanup-tree-dump "forwprop1" } } */ >> Index: gcc-head/gcc/testsuite/gcc.dg/tree-ssa/pr30978.c >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >> --- gcc-head.orig/gcc/testsuite/gcc.dg/tree-ssa/pr30978.c >> +++ gcc-head/gcc/testsuite/gcc.dg/tree-ssa/pr30978.c >> @@ -10,5 +10,5 @@ int foo(int a) >> =A0 return e; >> =A0} >> >> -/* { dg-final { scan-tree-dump "e_. =3D a_..D. > 0;" "optimized" } } */ >> +/* { dg-final { scan-tree-dump " =3D a_..D. > 0;" "optimized" } } */ >> =A0/* { dg-final { cleanup-tree-dump "optimized" } } */ >> Index: gcc-head/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-6.c >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >> --- gcc-head.orig/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-6.c >> +++ gcc-head/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-6.c >> @@ -2,5 +2,5 @@ >> =A0/* { dg-options "-O -fdump-tree-fre1-details" } */ >> >> =A0int i; int foo(void) { i =3D 2; int j =3D i * 2; int k =3D i + 2; ret= urn j =3D=3D k; } >> -/* { dg-final { scan-tree-dump-times "Replaced " 5 "fre1" } } */ >> +/* { dg-final { scan-tree-dump-times "Replaced " 6 "fre1" } } */ >> =A0/* { dg-final { cleanup-tree-dump "fre1" } } */ >> Index: gcc-head/gcc/tree-ssa-forwprop.c >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >> --- gcc-head.orig/gcc/tree-ssa-forwprop.c >> +++ gcc-head/gcc/tree-ssa-forwprop.c >> @@ -367,9 +367,61 @@ combine_cond_expr_cond (location_t loc, >> =A0 gcc_assert (TREE_CODE_CLASS (code) =3D=3D tcc_comparison); >> >> =A0 t =3D fold_binary_loc (loc, code, type, op0, op1); >> + >> + =A0if (!t && INTEGRAL_TYPE_P (TREE_TYPE (op1)) >> + =A0 =A0 =A0&& TYPE_PRECISION (TREE_TYPE (op1)) =3D=3D 1 >> + =A0 =A0 =A0&& (code =3D=3D EQ_EXPR || code =3D=3D NE_EXPR)) >> + =A0 =A0{ >> + =A0 =A0 =A0if (TREE_CODE (op1) =3D=3D INTEGER_CST) >> + =A0 =A0 =A0 =A0{ >> + =A0 =A0 =A0 =A0 if (integer_onep (op1)) >> + =A0 =A0 =A0 =A0 =A0 { >> + =A0 =A0 =A0 =A0 =A0 =A0 op1 =3D fold_convert_loc (loc, TREE_TYPE (op1)= , integer_zero_node); >> + =A0 =A0 =A0 =A0 =A0 =A0 code =3D (code =3D=3D NE_EXPR ? EQ_EXPR : NE_E= XPR); > > So you change truthvalue !=3D/=3D=3D 1 to truthvalue =3D=3D/!=3D 0 and th= en > recurse ... that doesn't make sense to me and is super-ugly. > What's the testcase that made you add all this code? Well, the convert from truthvalue !=3D/=3D=3D 1 to !=3D/=3D=3D 0 limits the= amount of cases to handle. As for truthvalued X the we have then just to handle two cases. X !=3D 0 -> X, and X =3D=3D 0 -> (X ^ 1). The recursion is someting I saw as existing pattern (for the same thing) in truth-op folding in fold-const. Actual I can remove this optimization here, as it should be convered by VRP already (when VRP handles 1-bit precision bitwise ops proper).