This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: extend fwprop optimization
- From: Uros Bizjak <ubizjak at gmail dot com>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: Wei Mi <wmi at google dot com>, Steven Bosscher <stevenb dot gcc at gmail dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, David Li <davidxl at google dot com>, Kirill Yukhin <kirill dot yukhin at gmail dot com>
- Date: Tue, 26 Mar 2013 19:23:08 +0100
- Subject: Re: extend fwprop optimization
- References: <CA+4CFy4N5+g0XVJ4vDtGyqHOgj15t3vDiiF0A8_1H9hKNZ+LuQ at mail dot gmail dot com> <CABu31nMvJnvWoj-xA-YkOeH5XLgj+8OLjALyxE+pMaA=s91_KA at mail dot gmail dot com> <CA+4CFy6q-HXCJ3jPQwGzV_beysTdEV-GVsY=0oFLbL-iDVaSbQ at mail dot gmail dot com> <CABu31nOAuZ16eQS+8fq=bntXXfzfzHT7aCZh_vnJG4xh45Yccg at mail dot gmail dot com> <CA+4CFy5++86xq8q7_4x-YuOCHSrpsZ4QST1J6KFK_X_EjxRh+A at mail dot gmail dot com> <CABu31nPB3t+b61fSndgbFD-Ps4SXo62872f2cOyRBOi0nW22ig at mail dot gmail dot com> <CA+4CFy6thk60J=4O626nFKC9t9ivYyg9jPtMHcBWGdM=t49Ubg at mail dot gmail dot com> <CA+4CFy5GkeRqe=9Q8tc688UiFXpe2vFS-QjKUpbuWLCRHV8coA at mail dot gmail dot com> <CABu31nN64RUCC8TBjUEunUMDcu0BAuV7+_JT2aogbJ4uybiRFw at mail dot gmail dot com> <CA+4CFy5fYWHAHWgzL+SNBm3H+LophqSEo3LMwqKgW2FCej2A9Q at mail dot gmail dot com> <CABu31nOtV85auTQa8mGFZ6Lnz81VQPbgoeXGLsu58PB0nLJ9JQ at mail dot gmail dot com> <CA+4CFy5fYFpUK3FmmWoVTrSxBamGhBy=+_dQEa24TSVLY62SiQ at mail dot gmail dot com> <CA+4CFy5qgj_vxOxouauPvwAWA77sWe6wmrN9MW90fOZVhS7KnQ at mail dot gmail dot com> <CAFiYyc2oGc4DArocxSdYbscDbmrsLWFgqJPWCfUD5pK5C6o+GQ at mail dot gmail dot com> <CA+4CFy4=kGL8b0AHfu=U+hTmYyhuUQEZKOMH0mRQ8u-GaL4BOg at mail dot gmail dot com> <CA+4CFy6=aETCjpoGHm22r5siwaYC1OzNDg08Jk=Ro8Uu3ZzvQQ at mail dot gmail dot com> <CAFiYyc3AfECj8j8Bzo+-Fv+Fm9+RbO3T=xG4sjH+3KFuJ_2Xgw at mail dot gmail dot com>
On Tue, Mar 26, 2013 at 10:14 AM, Richard Biener
<richard.guenther@gmail.com> wrote:
>>> I am trying to figure out a way not to lose the opportunity when shift
>>> truncation is not combined in a bit test pattern. Can we keep the
>>> explicit truncation in RTL, but generate truncation code in assembly?
>>> Then only shift truncation which not combined in a bit test
>>> pattershift truncationn will happen.
>>>
>>> (define_insn "*<shift_insn_and><mode>"
>>> [(set (match_operand:SWI48 0 "nonimmediate_operand" "=rm")
>>> (any_shiftrt:SWI48
>>> (match_operand:SWI48 1 "nonimmediate_operand" "0")
>>> (subreg:QI
>>> (and:SI
>>> (match_operand:SI 2 "nonimmediate_operand" "c")
>>> (match_operand:SI 3 "const_int_operand" "n")) 0)))
>>> (clobber (reg:CC FLAGS_REG))]
>>> "ix86_binary_operator_ok (<CODE>, <MODE>mode, operands)"
>>> {
>>> if ((INTVAL (operands[3]) & (GET_MODE_BITSIZE (<MODE>mode)-1))
>>> == GET_MODE_BITSIZE (<MODE>mode)-1)
>>> return "and\t{%3, %2|%2, %3}\n\r shift\t{%b2, %0|%0, %b2}";
>>> else
>>> "shift\t{%2, %0|%0, %2}";
>>> }
>>
>> Sorry, rectify a mistake:
>>
>> {
>> if ((INTVAL (operands[3]) & (GET_MODE_BITSIZE (<MODE>mode)-1))
>> == GET_MODE_BITSIZE (<MODE>mode)-1)
>> return "shift\t{%2, %0|%0, %2}";
>> else
>> return "and\t{%3, %2|%2, %3}\n\r shift\t{%b2, %0|%0, %b2}";
>> }
>
> I'm not sure the existing patterns are wrong because SHIFT_COUNT_TRUNCATED
> is false for x86 AFAIK, exactly because of the bit-test vs. shift instruction
> differences. So there is no inconsistency. The i386 backend seems to
> try to follow my suggestion as if SHIFT_COUNT_TRUNCATED didn't exist
> (well, it's false, so it technically doesn't exist for i386) and recognizes
> the shift with truncate with the *<shift_insn><mode>3_mask splitter.
> But I'm not sure why it bothers to do it with a splitter instead of just
> with a define_insn? Because the split code,
>
> [(parallel [(set (match_dup 0)
> (any_shiftrt:SWI48 (match_dup 1) (match_dup 2)))
> (clobber (reg:CC FLAGS_REG))])]
>
> is wrong and could be combined into a bit-test instruction. No?
>
> That is, why not have define_insn variants for shift instructions with
> explicit truncation?
You are right, the split is harmful in this case.
It looks to me, that explicit truncation can be added to split
patterns in the most elegant way using proposed "define_subst"
infrastructure.
Uros.