On 26/10/2020 07:12, Segher Boessenkool wrote: > Hi! > > On Thu, Oct 15, 2020 at 09:59:24AM +0100, Alex Coplan wrote: > > @@ -7650,20 +7650,27 @@ make_extraction (machine_mode mode, rtx inner, > > HOST_WIDE_INT pos, > > is_mode = GET_MODE (SUBREG_REG (inner)); > > inner = SUBREG_REG (inner); > > } > > + else if ((GET_CODE (inner) == ASHIFT || GET_CODE (inner) == MULT) > > + && pos_rtx == 0 && pos == 0) > > + { > > + const HOST_WIDE_INT ci = INTVAL (XEXP (inner, 1)); > > + const auto code = GET_CODE (inner); > > + const HOST_WIDE_INT shift_amt = (code == MULT) ? exact_log2 (ci) : > > ci; > > Can you instead replace the mult by a shift somewhere earlier in > make_extract? That would make a lot more sense :-)
I guess we could do this, the only complication being that we can't unconditionally rewrite the expression using a shift, since mult is canonical inside a mem (which is why we see it in the testcase in the PR). So if we did this, we'd have to remember that we did it earlier on, and rewrite it back to a mult accordingly. Would you still like to see a version of the patch that does that, or is this version OK: https://gcc.gnu.org/pipermail/gcc-patches/2020-October/557050.html ? Thanks, Alex