https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102622
--- Comment #22 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Here is the simple patch which I will test for both GCC 10 and GCC 9. The question becomes does it make sense to make the same change to GCC 11 even if it cannot be hit. diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c index 9ed26a3d45f..a6c197defea 100644 --- a/gcc/tree-ssa-phiopt.c +++ b/gcc/tree-ssa-phiopt.c @@ -770,9 +770,12 @@ conditional_replacement (basic_block cond_bb, basic_block middle_bb, if ((integer_zerop (arg0) && integer_onep (arg1)) || (integer_zerop (arg1) && integer_onep (arg0))) neg = false; + /* For signed one bit types, the negation is not needed and + should be avoided and is the same as 1 case for non-signed + one bit types. */ else if ((integer_zerop (arg0) && integer_all_onesp (arg1)) || (integer_zerop (arg1) && integer_all_onesp (arg0))) - neg = true; + neg = TYPE_PRECISION (TREE_TYPE (arg0)) != 1; else return false;