This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Transform (x >> cst) != 0 to x >= (1 << cst) and (x >> cst) == 0 to x < (1 << cst)


On 10/04/2017 12:34 PM, Prathamesh Kulkarni wrote:

>>> At a late stage, maybe during an RTL pass or expansion (or just before
>>> expansion) it would indeed be good to generate a shift for such
>>> comparisons, on targets where that sets a cc. The lack of this
>>> transformation could be considered a blocker for the other one, to avoid
>>> regressing on bar.
>> Right.  In fact, I think Jakub's test ought to be added to this work as
>> part of its basic testing.
> Um, how to write the above-test case for bar() in DejaGNU format ?
> Is it possible to test for number of insns or to use nm to test for
> size of a function with dejagnu directive ?
> Or should I scan for "cmpq" since the pattern transforms a right shift
> and cmp against 0 to cmp between operands ?
I've used a variety of approaches.  The difficulty in the x86 world is
that there's enough tuning variants that change the resulting code which
can make scanning problematical.

So one approach is to look at the total object size if that's a reliable
indicator of the issue at hand.

As an example see gcc.target/m68k/pr52076-?.c.  I'm sure there's others
if you were to search for "object-size" in the testsuite.

You could try to count the insns or search for specific key insns that
indicate we generated desirable or undesirable code.

But what might ultimately be best would be to scan the rtl at expansion
time.  That catches things at the earliest point we can observe them.

Another alternative would be to include some dumping code to indicate
when we transform the canonical gimple form into the form we want for
the x86 backend at rtl expansion.  You could then scan the debugging
dumps for those annotations.

jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]