From: Andrew Pinski <pinskia@gmail.com>
To: Bernd Edlinger <bernd.edlinger@hotmail.de>
Cc: Richard Biener <richard.guenther@gmail.com>,
Andrew Pinski <apinski@marvell.com>,
GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCHv2] Add a couple of A?CST1:CST2 match and simplify optimizations
Date: Wed, 26 May 2021 02:01:42 -0700 [thread overview]
Message-ID: <CA+=Sn1n6MfvrXYRueVx-1X7CqP-mCvMM3BQc8XkM59pzC_gimA@mail.gmail.com> (raw)
In-Reply-To: <AM8PR10MB470841C576030FA22B734C63E4249@AM8PR10MB4708.EURPRD10.PROD.OUTLOOK.COM>
On Wed, May 26, 2021 at 1:43 AM Bernd Edlinger
<bernd.edlinger@hotmail.de> wrote:
>
> On 5/25/21 4:22 PM, Richard Biener via Gcc-patches wrote:
> > On Sun, May 23, 2021 at 12:03 PM apinski--- via Gcc-patches
> > <gcc-patches@gcc.gnu.org> wrote:
> >>
> >> From: Andrew Pinski <apinski@marvell.com>
> >>
> >> Instead of some of the more manual optimizations inside phi-opt,
> >> it would be good idea to do a lot of the heavy lifting inside match
> >> and simplify instead. In the process, this moves the three simple
> >> A?CST1:CST2 (where CST1 or CST2 is zero) simplifications.
> >>
> >> OK? Boostrapped and tested on x86_64-linux-gnu with no regressions.
> >>
> >> Differences from V1:
> >> * Use bit_xor 1 instead of bit_not to fix the problem with boolean types
> >> which are not 1 bit precision.
> >
> > OK.
> >
> > Thanks,
> > Richard.
> >
>
> Hmm, sorry, no luck.
>
> I think this caused:
If anything it is a bad interaction with changes between r12-1046 and
r12-1053; I am suspecting a bug in those changes rather than my
changes causing the bug. Debugging it right now.
Thanks,
Andrew
>
> home/ed/gnu/gcc-build/./gcc/xgcc -B/home/ed/gnu/gcc-build/./gcc/ -B/home/ed/gnu/install/x86_64-pc-linux-gnu/bin/ -B/home/ed/gnu/install/x86_64-pc-linux-gnu/lib/ -isystem /home/ed/gnu/install/x86_64-pc-linux-gnu/include -isystem /home/ed/gnu/install/x86_64-pc-linux-gnu/sys-include -fchecking=1 -c -g -O2 -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wmissing-format-attribute -Wno-overlength-strings -pedantic -Wno-long-long -DHAVE_CONFIG_H -I. -I../../gcc-trunk/fixincludes -I../include -I../../gcc-trunk/fixincludes/../include ../../gcc-trunk/fixincludes/fixtests.c
> during GIMPLE pass: evrp
> ../../gcc-trunk/fixincludes/fixtests.c: In function ‘run_test’:
> ../../gcc-trunk/fixincludes/fixtests.c:155:1: internal compiler error: in operator[], at vec.h:890
> 155 | }
> | ^
> 0x824622 vec<tree_node*, va_gc, vl_embed>::operator[](unsigned int)
> ../../gcc-trunk/gcc/vec.h:890
> 0x8247f0 vec<range_def_chain::rdc, va_heap, vl_embed>::operator[](unsigned int)
> ../../gcc-trunk/gcc/tree.h:3366
> 0x8247f0 vec<range_def_chain::rdc, va_heap, vl_ptr>::operator[](unsigned int)
> ../../gcc-trunk/gcc/vec.h:1461
> 0x8247f0 range_def_chain::register_dependency(tree_node*, tree_node*, basic_block_def*)
> ../../gcc-trunk/gcc/gimple-range-gori.cc:179
> 0x18639bc fold_using_range::range_of_range_op(irange&, gimple*, fur_source&)
> ../../gcc-trunk/gcc/gimple-range.cc:439
> 0x1866c85 fold_using_range::fold_stmt(irange&, gimple*, fur_source&, tree_node*)
> ../../gcc-trunk/gcc/gimple-range.cc:376
> 0x1866fa2 gimple_ranger::fold_range_internal(irange&, gimple*, tree_node*)
> ../../gcc-trunk/gcc/gimple-range.cc:1067
> 0x1866fa2 gimple_ranger::range_of_stmt(irange&, gimple*, tree_node*)
> ../../gcc-trunk/gcc/gimple-range.cc:1097
> 0x186308a gimple_ranger::range_of_expr(irange&, tree_node*, gimple*)
> ../../gcc-trunk/gcc/gimple-range.cc:980
> 0x18637c7 fold_using_range::range_of_range_op(irange&, gimple*, fur_source&)
> ../../gcc-trunk/gcc/gimple-range.cc:431
> 0x1866c85 fold_using_range::fold_stmt(irange&, gimple*, fur_source&, tree_node*)
> ../../gcc-trunk/gcc/gimple-range.cc:376
> 0x1866fa2 gimple_ranger::fold_range_internal(irange&, gimple*, tree_node*)
> ../../gcc-trunk/gcc/gimple-range.cc:1067
> 0x1866fa2 gimple_ranger::range_of_stmt(irange&, gimple*, tree_node*)
> ../../gcc-trunk/gcc/gimple-range.cc:1097
> 0x186308a gimple_ranger::range_of_expr(irange&, tree_node*, gimple*)
> ../../gcc-trunk/gcc/gimple-range.cc:980
> 0x1149961 range_query::value_of_expr(tree_node*, gimple*)
> ../../gcc-trunk/gcc/value-query.cc:86
> 0x1871e51 hybrid_folder::value_of_expr(tree_node*, gimple*)
> ../../gcc-trunk/gcc/gimple-ssa-evrp.c:235
> 0xff9573 substitute_and_fold_engine::replace_uses_in(gimple*)
> ../../gcc-trunk/gcc/tree-ssa-propagate.c:575
> 0xff988c substitute_and_fold_dom_walker::before_dom_children(basic_block_def*)
> ../../gcc-trunk/gcc/tree-ssa-propagate.c:845
> 0x183921f dom_walker::walk(basic_block_def*)
> ../../gcc-trunk/gcc/domwalk.c:309
> 0xff8d15 substitute_and_fold_engine::substitute_and_fold(basic_block_def*)
> ../../gcc-trunk/gcc/tree-ssa-propagate.c:987
> Please submit a full bug report,
> with preprocessed source if appropriate.
> Please include the complete backtrace with any bug report.
> See <https://gcc.gnu.org/bugs/> for instructions.
> make[2]: *** [Makefile:76: fixtests.o] Error 1
> make[2]: Leaving directory '/home/ed/gnu/gcc-build/fixincludes'
> make[1]: *** [Makefile:3827: all-fixincludes] Error 2
> make[1]: Leaving directory '/home/ed/gnu/gcc-build'
> make: *** [Makefile:1011: all] Error 2
>
>
> Bernd.
>
>
> >> Thanks,
> >> Andrew Pinski
> >>
> >> gcc:
> >> * match.pd (A?CST1:CST2): Add simplifcations for A?0:+-1, A?+-1:0,
> >> A?POW2:0 and A?0:POW2.
> >> ---
> >> gcc/match.pd | 41 +++++++++++++++++++++++++++++++++++++++++
> >> 1 file changed, 41 insertions(+)
> >>
> >> diff --git a/gcc/match.pd b/gcc/match.pd
> >> index 1fc6b7b1557..ad6b057c56d 100644
> >> --- a/gcc/match.pd
> >> +++ b/gcc/match.pd
> >> @@ -3711,6 +3711,47 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
> >> (if (integer_all_onesp (@1) && integer_zerop (@2))
> >> @0))))
> >>
> >> +/* A few simplifications of "a ? CST1 : CST2". */
> >> +/* NOTE: Only do this on gimple as the if-chain-to-switch
> >> + optimization depends on the gimple to have if statements in it. */
> >> +#if GIMPLE
> >> +(simplify
> >> + (cond @0 INTEGER_CST@1 INTEGER_CST@2)
> >> + (switch
> >> + (if (integer_zerop (@2))
> >> + (switch
> >> + /* a ? 1 : 0 -> a if 0 and 1 are integral types. */
> >> + (if (integer_onep (@1))
> >> + (convert (convert:boolean_type_node @0)))
> >> + /* a ? -1 : 0 -> -a. */
> >> + (if (integer_all_onesp (@1))
> >> + (negate (convert (convert:boolean_type_node @0))))
> >> + /* a ? powerof2cst : 0 -> a << (log2(powerof2cst)) */
> >> + (if (!POINTER_TYPE_P (type) && integer_pow2p (@1))
> >> + (with {
> >> + tree shift = build_int_cst (integer_type_node, tree_log2 (@1));
> >> + }
> >> + (lshift (convert (convert:boolean_type_node @0)) { shift; })))))
> >> + (if (integer_zerop (@1))
> >> + (with {
> >> + tree booltrue = constant_boolean_node (true, boolean_type_node);
> >> + }
> >> + (switch
> >> + /* a ? 0 : 1 -> !a. */
> >> + (if (integer_onep (@2))
> >> + (convert (bit_xor (convert:boolean_type_node @0) { booltrue; } )))
> >> + /* a ? -1 : 0 -> -(!a). */
> >> + (if (integer_all_onesp (@2))
> >> + (negate (convert (bit_xor (convert:boolean_type_node @0) { booltrue; } ))))
> >> + /* a ? powerof2cst : 0 -> (!a) << (log2(powerof2cst)) */
> >> + (if (!POINTER_TYPE_P (type) && integer_pow2p (@2))
> >> + (with {
> >> + tree shift = build_int_cst (integer_type_node, tree_log2 (@2));
> >> + }
> >> + (lshift (convert (bit_xor (convert:boolean_type_node @0) { booltrue; } ))
> >> + { shift; }))))))))
> >> +#endif
> >> +
> >> /* Simplification moved from fold_cond_expr_with_comparison. It may also
> >> be extended. */
> >> /* This pattern implements two kinds simplification:
> >> --
> >> 2.17.1
> >>
> >
next prev parent reply other threads:[~2021-05-26 9:01 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-23 9:41 apinski
2021-05-25 14:22 ` Richard Biener
2021-05-26 8:28 ` Bernd Edlinger
2021-05-26 9:01 ` Andrew Pinski [this message]
2021-05-26 11:07 ` Andrew Pinski
2021-05-26 11:27 ` Richard Biener
2021-05-26 11:37 ` Andrew Pinski
2021-05-26 12:05 ` Richard Biener
2021-05-26 16:59 ` Andrew MacLeod
2021-05-26 17:03 ` Bernd Edlinger
2021-05-26 17:07 ` Bernd Edlinger
2021-05-26 17:15 ` Andrew MacLeod
2021-05-26 16:54 ` Aldy Hernandez
2021-05-26 17:29 ` Andrew MacLeod
2021-05-28 4:53 ` Jeff Law
2021-05-28 7:16 ` Richard Biener
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CA+=Sn1n6MfvrXYRueVx-1X7CqP-mCvMM3BQc8XkM59pzC_gimA@mail.gmail.com' \
--to=pinskia@gmail.com \
--cc=apinski@marvell.com \
--cc=bernd.edlinger@hotmail.de \
--cc=gcc-patches@gcc.gnu.org \
--cc=richard.guenther@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).