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: Move some bit and binary optimizations in simplify and match


On Thu, Oct 8, 2015 at 8:15 PM, Bernd Schmidt <bschmidt@redhat.com> wrote:
> On 10/08/2015 08:03 PM, Joseph Myers wrote:
>>
>> On Thu, 8 Oct 2015, Bernd Schmidt wrote:
>>
>>> On 10/07/2015 11:54 AM, Hurugalawadi, Naveen wrote:
>>>>
>>>>         Move Fold X & (X ^ Y) as X & ~Y to match.pd.
>>>>         Move Fold X & (Y ^ X) as ~Y & X to match.pd.
>>>
>>>
>>> I wonder if we shouldn't try to autogenerate patterns such as these. I
>>> did
>>> something like that for a different project a long time ago. Generate
>>> expressions up to a certain level of complexity, identify which ones are
>>> equivalent, and pick the one with the lowest cost for simplifications...
>>
>>
>> Any bitwise expression whose ultimate operands are X, Y, 0 and -1
>> (possibly with conversions among types of the same width) could be
>> canonicalized to one of: 0, -1, X, Y, ~X, ~Y, X^Y, X^~Y, A&B or A|B (where
>> A is X or ~X and B is Y or ~Y).  I don't guarantee those are the best
>> canonical forms, but if you're folding this sort of expression you ought
>> to be able to make GCC fold all such expressions down to some such form
>> (and fold away all equality comparisons among such expressions with
>> constant value).
>
>
> I was actually thinking of also doing this for more complex expressions with
> more than two different operands.

Note that the optimization problem in general is more complicated and
involves multiple such expressions which should be associated/optimized
with CSE in mind to result in the minimal number of overall instructions
needed to compute all required values.

But yes, we could auto-generate patterns up to a specific depth or up
to a point where more complex patterns are handled by composition.
Patches welcome ;)

Richard.

>
> Bernd


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