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: [patch tree-optimization]: Do bitwise operator optimizations for X op !X patterns


----- Original Message -----
From: "Kai Tietz" <ktietz@redhat.com>
To: "Richard Guenther" <richard.guenther@gmail.com>
Cc: gcc-patches@gcc.gnu.org
Sent: Wednesday, June 29, 2011 1:33:30 PM
Subject: Re: [patch tree-optimization]: Do bitwise operator optimizations for X op !X patterns

----- Original Message -----
From: "Richard Guenther" <richard.guenther@gmail.com>
To: "Kai Tietz" <ktietz@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Sent: Wednesday, June 29, 2011 12:14:10 PM
Subject: Re: [patch tree-optimization]: Do bitwise operator optimizations for X op !X patterns

On Tue, Jun 28, 2011 at 5:05 PM, Kai Tietz <ktietz@redhat.com> wrote:
> Hello,
>
> this patch implements the X op !X patterns within tree-ssa-forwprop.c without using here const-fold routines. ÂAdditionally it does some trivial folding for X op X. ÂImplementation
> also looks through [(type)] X op [(type)] !X, if type of X is integral and precision is suitable
> for operation.
>
> ChangeLog gcc/
>
> 2011-06-28 ÂKai Tietz Â<ktietz@redhat.com>
>
> Â Â Â Â* tree-ssa-forwprop.c (operand_precision_onep): New
> Â Â Â Âfunction.
> Â Â Â Â(find_possible_not_expr_argument): Likewise.
> Â Â Â Â(simplify_bitwise_binary_1): Likewise.
> Â Â Â Â(simplify_bitwise_binary): Use simplify_bitwise_binary_1
> Â Â Â Âfor detecting various X op !X optimizations.
>
> ChangeLog gcc/testsuite
>
> 2011-06-28 ÂKai Tietz Â<ktietz@redhat.com>
>
> Â Â Â Â* gcc.dg/binop-notand1a.c: New test.
> Â Â Â Â* gcc.dg/binop-notand2a.c: New test.
> Â Â Â Â* gcc.dg/binop-notand3a.c: New test.
> Â Â Â Â* gcc.dg/binop-notand4a.c: New test.
> Â Â Â Â* gcc.dg/binop-notand5a.c: New test.
> Â Â Â Â* gcc.dg/binop-notand6a.c: New test.
> Â Â Â Â* gcc.dg/binop-notor1.c: New test.
> Â Â Â Â* gcc.dg/binop-notor2.c: New test.
> Â Â Â Â* gcc.dg/binop-notxor1.c: New test.
> Â Â Â Â* gcc.dg/binop-notxor2.c: New test.
>
> Bootstrapped and regression tested for all languages plus Ada and Obj-C for x86_64-pc-linux-gnu. Ok for apply?

I can't follow the code in find_possible_not_expr_argument or its uses
at all.  Please try to produce patches that look more obvious in what
they are doing - don't try to solve every testcase you can come up with
in a single patch.  Especially don't write functions like
find_possible_not_expr_argument which seems to have evolved a lot
after you wrote the overall function comment.

Thanks,
Richard.

> Regards,
> Kai
>

Well, I added some comments to these functions and renamed the find_possible_not_expr_argument function to detect_not_expr_operand, which hits its use better.
The cause for this function is, that there are more then one variant of expressing a logical-not and all of them are used.
This routine simply tries to detect different variants used for not. Eg ~X == !X and (X ^ 1) == !X for integral type of X with precision one. For X with integral type, (X == 0) == !X.

The folding for the three different bitwise-operations is pretty easy and it makes sense to implement them at once.  I see here no good point to separate them into different patches.  To separate them might even lead to questions about abstracting some code-pieces out of the main function.
I didn't added testcases for all variants I am aware now. Just those, which are now handled.

So hope you can read and understand logic of patch better by updated patch.

Regards,
Kai

I found that in version I've sent there is an unclosed comment.  So here is updated patch, which additionally simplify some code to ease reading.

Regards,
Kai

Attachment: fold_fw.txt
Description: Text document


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