* [Bug tree-optimization/108354] [13 Regression] Dead Code Elimination Regression at -O2 since r13-89-gb3e98eb3396e16
2023-01-10 12:41 [Bug tree-optimization/108354] New: Dead Code Elimination Regression at -O2 (trunk vs. 12.2.0) yann at ywg dot ch
@ 2023-01-10 14:44 ` marxin at gcc dot gnu.org
2023-01-31 4:33 ` pinskia at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: marxin at gcc dot gnu.org @ 2023-01-10 14:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108354
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|Dead Code Elimination |[13 Regression] Dead Code
|Regression at -O2 (trunk |Elimination Regression at
|vs. 12.2.0) |-O2 since
| |r13-89-gb3e98eb3396e16
Ever confirmed|0 |1
Target Milestone|--- |13.0
Status|UNCONFIRMED |NEW
CC| |marxin at gcc dot gnu.org,
| |sayle at gcc dot gnu.org
Last reconfirmed| |2023-01-10
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/108354] [13 Regression] Dead Code Elimination Regression at -O2 since r13-89-gb3e98eb3396e16
2023-01-10 12:41 [Bug tree-optimization/108354] New: Dead Code Elimination Regression at -O2 (trunk vs. 12.2.0) yann at ywg dot ch
2023-01-10 14:44 ` [Bug tree-optimization/108354] [13 Regression] Dead Code Elimination Regression at -O2 since r13-89-gb3e98eb3396e16 marxin at gcc dot gnu.org
@ 2023-01-31 4:33 ` pinskia at gcc dot gnu.org
2023-01-31 4:52 ` pinskia at gcc dot gnu.org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-01-31 4:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108354
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |pinskia at gcc dot gnu.org
Status|NEW |ASSIGNED
Depends on| |96921
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Looks like:
_4 = (int) _2;
...
i.1_15 = (unsigned short) _2;
_16 = 1 - i.1_15;
_6 = (int) _16;
...
_8 = _4 | _6;
Simplify to just
_4 = (int) _2;
...
_t = _2 ^ 1;
_6 = (int)_t;
...
_8 = _4 | _6;
Which then simplifies down to:
_8 = 1; (because (_2 ^ 1) | (_2) == 1)
Which then would be optimized.
Let me look.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96921
[Bug 96921] Failure to optimize combined boolean not patterns
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/108354] [13 Regression] Dead Code Elimination Regression at -O2 since r13-89-gb3e98eb3396e16
2023-01-10 12:41 [Bug tree-optimization/108354] New: Dead Code Elimination Regression at -O2 (trunk vs. 12.2.0) yann at ywg dot ch
2023-01-10 14:44 ` [Bug tree-optimization/108354] [13 Regression] Dead Code Elimination Regression at -O2 since r13-89-gb3e98eb3396e16 marxin at gcc dot gnu.org
2023-01-31 4:33 ` pinskia at gcc dot gnu.org
@ 2023-01-31 4:52 ` pinskia at gcc dot gnu.org
2023-01-31 8:23 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-01-31 4:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108354
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This is a specific case of PR 91213 and the case which will also fix PR 96921:
/* 1 - a is a ^ 1 if a had a bool range. */
(simplify
(minus integer_onep@0 SSA_NAME@1)
(if (INTEGRAL_TYPE_P (type)
&& ssa_name_has_boolean_range (@1))
(bit_xor @1 @0)))
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/108354] [13 Regression] Dead Code Elimination Regression at -O2 since r13-89-gb3e98eb3396e16
2023-01-10 12:41 [Bug tree-optimization/108354] New: Dead Code Elimination Regression at -O2 (trunk vs. 12.2.0) yann at ywg dot ch
` (2 preceding siblings ...)
2023-01-31 4:52 ` pinskia at gcc dot gnu.org
@ 2023-01-31 8:23 ` pinskia at gcc dot gnu.org
2023-01-31 20:01 ` pinskia at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-01-31 8:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108354
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #2)
> This is a specific case of PR 91213 and the case which will also fix PR
> 96921:
>
> /* 1 - a is a ^ 1 if a had a bool range. */
> (simplify
> (minus integer_onep@0 SSA_NAME@1)
> (if (INTEGRAL_TYPE_P (type)
> && ssa_name_has_boolean_range (@1))
> (bit_xor @1 @0)))
I might be running into an Ada build failure with this patch; I am double
checking this now. It also could be a latent bug ...
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/108354] [13 Regression] Dead Code Elimination Regression at -O2 since r13-89-gb3e98eb3396e16
2023-01-10 12:41 [Bug tree-optimization/108354] New: Dead Code Elimination Regression at -O2 (trunk vs. 12.2.0) yann at ywg dot ch
` (3 preceding siblings ...)
2023-01-31 8:23 ` pinskia at gcc dot gnu.org
@ 2023-01-31 20:01 ` pinskia at gcc dot gnu.org
2023-01-31 20:06 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-01-31 20:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108354
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #3)
> (In reply to Andrew Pinski from comment #2)
> > This is a specific case of PR 91213 and the case which will also fix PR
> > 96921:
> >
> > /* 1 - a is a ^ 1 if a had a bool range. */
> > (simplify
> > (minus integer_onep@0 SSA_NAME@1)
> > (if (INTEGRAL_TYPE_P (type)
> > && ssa_name_has_boolean_range (@1))
> > (bit_xor @1 @0)))
>
> I might be running into an Ada build failure with this patch; I am double
> checking this now. It also could be a latent bug ...
I added an extra check for TYPE_UNSIGNED and there is still an issue.
I suspect there might be a latent bug happening somewhere.
apinski@xeond:~/src/upstream-gcc/gcc/objdir/gcc/ada/tools$ ../../xgcc -B../../
-c -g -O2 -W -Wall -gnatpg -gnata -I- -I../rts -I.
-I/home/apinski/src/upstream-gcc/gcc/gcc/ada
/home/apinski/src/upstream-gcc/gcc/gcc/ada/gnatlink.adb -o gnatlink.o -v
Reading specs from ../../specs
COLLECT_GCC=../../xgcc
Target: x86_64-pc-linux-gnu
Configured with: /home/apinski/src/upstream-gcc/gcc/configure
--prefix=/home/apinski/upstream-gcc
--enable-languages=c,c++,fortran,lto,objc,go,ada
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 13.0.1 20230131 (experimental) [master 733988099bc] (GCC)
COLLECT_GCC_OPTIONS='-B' '../../' '-c' '-g' '-O2' '-Wextra' '-Wall' '-gnatpg'
'-gnata' '-I' '-' '-I' '../rts' '-I' '.' '-I'
'/home/apinski/src/upstream-gcc/gcc/gcc/ada' '-o' 'gnatlink.o' '-v'
'-mtune=generic' '-march=x86-64'
../../gnat1 -I - -I ../rts -I . -I /home/apinski/src/upstream-gcc/gcc/gcc/ada
-quiet -O2 -Wextra -Wall -dumpbase gnatlink.adb -dumpbase-ext .adb -gnatwa -g
-gnatpg -gnata -mtune=generic -march=x86-64 -gnatO gnatlink.o
/home/apinski/src/upstream-gcc/gcc/gcc/ada/gnatlink.adb -o /tmp/ccn5ePu7.s
raised STORAGE_ERROR : stack overflow or erroneous memory access
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/108354] [13 Regression] Dead Code Elimination Regression at -O2 since r13-89-gb3e98eb3396e16
2023-01-10 12:41 [Bug tree-optimization/108354] New: Dead Code Elimination Regression at -O2 (trunk vs. 12.2.0) yann at ywg dot ch
` (4 preceding siblings ...)
2023-01-31 20:01 ` pinskia at gcc dot gnu.org
@ 2023-01-31 20:06 ` pinskia at gcc dot gnu.org
2023-01-31 20:07 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-01-31 20:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108354
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #4)
> raised STORAGE_ERROR : stack overflow or erroneous memory access
0x00000000015769b4 in get_range_query (fun=<optimized out>) at
/home/apinski/src/upstream-gcc/gcc/gcc/value-query.h:143
143 return fun->x_range_query ? fun->x_range_query : &global_ranges;
(gdb) bt
#0 0x00000000015769b4 in get_range_query (fun=<optimized out>) at
/home/apinski/src/upstream-gcc/gcc/gcc/value-query.h:143
#1 ssa_name_has_boolean_range(tree_node*) () at
/home/apinski/src/upstream-gcc/gcc/gcc/tree-ssanames.cc:534
#2 0x0000000001ae01a6 in generic_simplify_MINUS_EXPR(unsigned int, tree_code,
tree_node*, tree_node*, tree_node*) [clone .constprop.0] () at
/home/apinski/src/upstream-gcc/gcc/gcc/tree.h:3654
#3 0x0000000000fb1286 in fold_binary_loc(unsigned int, tree_code, tree_node*,
tree_node*, tree_node*) () at
/home/apinski/src/upstream-gcc/gcc/gcc/fold-const.cc:10926
#4 0x0000000000fb8eeb in fold_build2_loc (loc=loc@entry=0,
code=code@entry=MINUS_EXPR, type=0x7ffff725c000, op0=op0@entry=0x7ffff7242d50,
op1=op1@entry=0x7ffff52a6870) at
/home/apinski/src/upstream-gcc/gcc/gcc/fold-const.cc:13824
#5 0x0000000000f7373f in get_inner_reference(tree_node*, poly_int_pod<1u,
long>*, poly_int_pod<1u, long>*, tree_node**, machine_mode*, int*, int*, int*)
() at /home/apinski/src/upstream-gcc/gcc/gcc/tree.h:3645
#6 0x00000000010a2546 in (anonymous
namespace)::isra_analyze_call(cgraph_edge*) () at
/home/apinski/src/upstream-gcc/gcc/gcc/ipa-sra.cc:2167
#7 0x00000000010a32a8 in (anonymous
namespace)::isra_analyze_all_outgoing_calls (node=<error reading variable:
dwarf2_find_location_expression: Corrupted DWARF expression.>) at
/home/apinski/src/upstream-gcc/gcc/gcc/ipa-sra.cc:2202
#8 ipa_sra_summarize_function(cgraph_node*) () at
/home/apinski/src/upstream-gcc/gcc/gcc/ipa-sra.cc:4540
#9 0x00000000010a5558 in (anonymous namespace)::ipa_sra_generate_summary() ()
at /home/apinski/src/upstream-gcc/gcc/gcc/ipa-sra.cc:2716
#10 0x0000000001242f23 in execute_ipa_summary_passes (ipa_pass=0x3a90670) at
/home/apinski/src/upstream-gcc/gcc/gcc/passes.cc:2297
(gdb) p cfun
$3 = (function *) 0x0
Ok, let me mark the pattern only for GIMPLE because it looks like we are
calling fold without setting cfun and still passing a SSA_NAME.
I suspect we might run into this issue with other code too but at least I hide
the latent bug ...
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/108354] [13 Regression] Dead Code Elimination Regression at -O2 since r13-89-gb3e98eb3396e16
2023-01-10 12:41 [Bug tree-optimization/108354] New: Dead Code Elimination Regression at -O2 (trunk vs. 12.2.0) yann at ywg dot ch
` (5 preceding siblings ...)
2023-01-31 20:06 ` pinskia at gcc dot gnu.org
@ 2023-01-31 20:07 ` pinskia at gcc dot gnu.org
2023-02-14 21:47 ` pinskia at gcc dot gnu.org
2023-02-14 21:48 ` pinskia at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-01-31 20:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108354
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Full backtrace:
(gdb) bt
#0 0x000000000158208f in get_range_query (fun=0x0) at
/home/apinski/src/upstream-gcc/gcc/gcc/value-query.h:143
#1 0x0000000001e4a9f0 in ssa_name_has_boolean_range (op=0x7ffff52a6870) at
/home/apinski/src/upstream-gcc/gcc/gcc/tree-ssanames.cc:534
#2 0x00000000026a6e33 in generic_simplify_MINUS_EXPR (loc=0, code=MINUS_EXPR,
type=0x7ffff725c000, _p0=0x7ffff7242d50, _p1=0x7ffff52a6870) at
generic-match.cc:36418
#3 0x00000000027c9064 in generic_simplify (loc=0, code=MINUS_EXPR,
type=0x7ffff725c000, _p0=0x7ffff7242d50, _p1=0x7ffff52a6870) at
generic-match.cc:103671
#4 0x00000000015670c0 in fold_binary_loc (loc=0, code=MINUS_EXPR,
type=0x7ffff725c000, op0=0x7ffff7242d50, op1=0x7ffff52a6870) at
/home/apinski/src/upstream-gcc/gcc/gcc/fold-const.cc:10926
#5 0x0000000001575b6a in fold_build2_loc (loc=0, code=MINUS_EXPR,
type=0x7ffff725c000, op0=0x7ffff7242d50, op1=0x7ffff52a6870) at
/home/apinski/src/upstream-gcc/gcc/gcc/fold-const.cc:13824
#6 0x000000000150714d in get_inner_reference (exp=0x7ffff5a89540,
pbitsize=0x7fffffffd5a8, pbitpos=0x7fffffffd5b0, poffset=0x7fffffffd568,
pmode=0x7fffffffd54c, punsignedp=0x7fffffffd550, preversep=0x7fffffffd554,
pvolatilep=0x7fffffffd560) at
/home/apinski/src/upstream-gcc/gcc/gcc/expr.cc:7995
#7 0x00000000016dac07 in (anonymous namespace)::isra_analyze_call
(cs=0x7ffff4e59888) at /home/apinski/src/upstream-gcc/gcc/gcc/ipa-sra.cc:2167
#8 0x00000000016dad39 in (anonymous
namespace)::isra_analyze_all_outgoing_calls (node=0x7ffff5a38cc0) at
/home/apinski/src/upstream-gcc/gcc/gcc/ipa-sra.cc:2202
#9 0x00000000016e2295 in ipa_sra_summarize_function (node=0x7ffff5a38cc0) at
/home/apinski/src/upstream-gcc/gcc/gcc/ipa-sra.cc:4540
#10 0x00000000016dc4e0 in (anonymous namespace)::ipa_sra_generate_summary () at
/home/apinski/src/upstream-gcc/gcc/gcc/ipa-sra.cc:2716
#11 0x000000000195ef94 in execute_ipa_summary_passes (ipa_pass=0x52a9270) at
/home/apinski/src/upstream-gcc/gcc/gcc/passes.cc:2297
#12 0x00000000013b8699 in ipa_passes () at
/home/apinski/src/upstream-gcc/gcc/gcc/cgraphunit.cc:2226
#13 0x00000000013b8987 in symbol_table::compile (this=0x7ffff7246000) at
/home/apinski/src/upstream-gcc/gcc/gcc/cgraphunit.cc:2322
#14 0x00000000013b8f7c in symbol_table::finalize_compilation_unit
(this=0x7ffff7246000) at
/home/apinski/src/upstream-gcc/gcc/gcc/cgraphunit.cc:2574
#15 0x0000000001ac4ae9 in compile_file () at
/home/apinski/src/upstream-gcc/gcc/gcc/toplev.cc:471
#16 0x0000000001ac7b29 in do_compile (no_backend=false) at
/home/apinski/src/upstream-gcc/gcc/gcc/toplev.cc:2125
#17 0x0000000001ac7f11 in toplev::main (this=0x7fffffffdba2, argc=28,
argv=0x7fffffffdca8) at /home/apinski/src/upstream-gcc/gcc/gcc/toplev.cc:2277
#18 0x00000000034a7ea1 in main (argc=28, argv=0x7fffffffdca8) at
/home/apinski/src/upstream-gcc/gcc/gcc/main.cc:39
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/108354] [13 Regression] Dead Code Elimination Regression at -O2 since r13-89-gb3e98eb3396e16
2023-01-10 12:41 [Bug tree-optimization/108354] New: Dead Code Elimination Regression at -O2 (trunk vs. 12.2.0) yann at ywg dot ch
` (6 preceding siblings ...)
2023-01-31 20:07 ` pinskia at gcc dot gnu.org
@ 2023-02-14 21:47 ` pinskia at gcc dot gnu.org
2023-02-14 21:48 ` pinskia at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-02-14 21:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108354
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|ASSIGNED |RESOLVED
--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/108354] [13 Regression] Dead Code Elimination Regression at -O2 since r13-89-gb3e98eb3396e16
2023-01-10 12:41 [Bug tree-optimization/108354] New: Dead Code Elimination Regression at -O2 (trunk vs. 12.2.0) yann at ywg dot ch
` (7 preceding siblings ...)
2023-02-14 21:47 ` pinskia at gcc dot gnu.org
@ 2023-02-14 21:48 ` pinskia at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-02-14 21:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108354
Bug 108354 depends on bug 96921, which changed state.
Bug 96921 Summary: Failure to optimize combined boolean not patterns
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96921
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
^ permalink raw reply [flat|nested] 10+ messages in thread