https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118755

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---

So fwprop can't do this

```
propagating insn 11 into insn 12, replacing:
(set (reg:QI 107 [ _3 ])
    (subreg:QI (reg:SI 108) 0))
failed to match this instruction:
(set (reg:QI 107 [ _3 ])
    (subreg:QI (eq:SI (reg:CC 66 cc)
            (const_int 0 [0])) 0))
```

But combine does:

```
Trying 11 -> 12:
   11: r108:SI=cc:CC==0
      REG_DEAD cc:CC
   12: r107:QI=r108:SI#0
      REG_DEAD r108:SI
Successfully matched this instruction:
(set (reg:QI 107 [ _3 ])
    (eq:QI (reg:CC 66 cc)
        (const_int 0 [0])))
allowing combination of insns 11 and 12
```


This is due to this code in gen_lowpart_for_combine:
```
  /* If X is a comparison operator, rewrite it in a new mode.  This
     probably won't match, but may allow further simplifications.  */
  else if (COMPARISON_P (x)
           && SCALAR_INT_MODE_P (imode)
           && SCALAR_INT_MODE_P (omode))
    return gen_rtx_fmt_ee (GET_CODE (x), omode, XEXP (x, 0), XEXP (x, 1));
```

The question should we try to do another replacement in fwprop/late_combine for
stuff like this to simplify?

We have the same issue with (zero_extend (comparison)) too.

Let me see if adding them can help here too.

Reply via email to