I don't have a testcase for this one as convert already does it though with my tree combiner (or when TER folds), you can reproduce it with: int f(int i, int j) { _Bool a = i == j; int t = a; return t; }
I have a patch which I will be submitting after I do a bootstrap/test.
Created attachment 9607 [details] patch which I am testing
Note, type and TREE_CODE (op0) are swapped in the patch (as I did not even build the orginal patch).
I am retesting the patch and will apply after a bootstrap/test is finished.
Subject: Bug 23606 Author: pinskia Date: Tue Nov 22 19:22:21 2005 New Revision: 107370 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=107370 Log: 2005-11-22 Andrew Pinski <pinskia@physics.uc.edu> PR middle-end/23606 * fold-const.c (fold_unary) <case NOP_EXPR, CONVERT_EXPR>: For COMPARISON_CLASS_P and an integral types create create a new expression with the new type and fold that. Modified: trunk/gcc/ChangeLog trunk/gcc/fold-const.c
Fixed.