On 10/25/23 10:25, Vineet Gupta wrote:
Hey Robin,

On 10/25/23 00:12, Robin Dapp wrote:
Hi Vineet,

I was thinking of two things while skimming the code:

  - Couldn't we do this in the expanders directly?  Or is the
    subreg-promoted info gone until we reach that?

Following is the call stack involved:

   expand_gimple_cond
     do_compare_and_jump
        emit_cmp_and_jump_insns
            gen_cbranchqi4
                riscv_expand_conditional_branch
                    riscv_emit_int_compare
                       riscv_extend_comparands


Last function is what introduces the extraneous sign extends, w/o taking subreg-promoted into consideration and what my patch attempts to address.

  - Should some common-code part be more suited to handle that?
    We already elide redundant sign-zero extensions for other
    reasons.  Maybe we could add subreg promoted handling there?

Not in the context of this specific issue.
Robin's point (IIUC) is that if we put this logic into a zero/sign extend expander, then it'll get used for *any* attempt to zero/sign extend that goes through the target expander.

It doesn't work for your case because we use gen_rtx_{ZERO,SIGN}_EXTEND directly. But if those were adjusted to use the expander, then Robin's idea would be applicable to this case too.

Jeff

Reply via email to