Hi Suwa-san,

On Mon, Jun 17, 2024 at 04:17:15PM +0900, Takayuki 'January June' Suwa wrote:
> The previous constant synthesis logic had some issues that were non-fatal
> but worth considering:
> 
> - It didn't work with DFmode literals, because those were cast to SImode
>   rather SFmode when splitting into two natural-width words by
>   split_double().
> 
> - It didn't work with large literals when TARGET_AUTO_LITPOOLS was enabled,
>   because those were relaxed MOVI immediates rather references to literal
>   pool entries,
> 
> - It didn't take into account that when literals with the same RTL
>   representation are pooled multiple times within a function, those entries
>   are shared (especially important when optimizing for size).
> 
> This patch addresses the above issues by making appropriate tweaks to the
> constant synthesis logic.
> 
> gcc/ChangeLog:
> 
>       * config/xtensa/xtensa-protos.h (xtensa_constantsynth):
>       Change the second argument from HOST_WIDE_INT to rtx.
>       * config/xtensa/xtensa.cc (#include):
>       Add "context.h" and "pass_manager.h".
>       (machine_function): Add a new hash_map field "litpool_usage".
>       (xtensa_constantsynth): Make "src" (the second operand) accept
>       RTX literal instead of its value, and treat both bare and pooled
>       SI/SFmode literals equally by bit-exact canonicalization into
>       CONST_INT RTX internally.  And then, make avoid synthesis if
>       such multiple identical canonicalized literals are found in same
>       function when optimizing for size.  Finally, for literals where
>       synthesis is not possible or has been avoided, re-emit "move"
>       RTXes with canonicalized ones to increase the chances of sharing
>       literal pool entries.
>       * config/xtensa/xtensa.md (split patterns for constant synthesis):
>       Change to simply invoke xtensa_constantsynth() as mentioned above,
>       and add new patterns for when TARGET_AUTO_LITPOOLS is enabled.
> ---
>  gcc/config/xtensa/xtensa-protos.h |  2 +-
>  gcc/config/xtensa/xtensa.cc       | 75 ++++++++++++++++++++++++++++---
>  gcc/config/xtensa/xtensa.md       | 56 ++++++++++++++---------
>  3 files changed, 103 insertions(+), 30 deletions(-)

This series introduced a few ICE regressions:

+FAIL: gcc.dg/atomic/c11-atomic-exec-2.c   -Os  (internal compiler error: 
Segmentation fault)
+FAIL: gcc.dg/atomic/c11-atomic-exec-3.c   -Os  (internal compiler error: 
Segmentation fault)
+FAIL: gcc.dg/atomic/c11-atomic-exec-4.c   -Os  (internal compiler error: 
Segmentation fault)
+FAIL: gcc.dg/torture/vec-cvt-1.c   -Os  (internal compiler error: Segmentation 
fault)
+FAIL: c-c++-common/torture/complex-sign-mixed-add.c   -Os  (internal compiler 
error: Segmentation fault)
+FAIL: c-c++-common/torture/complex-sign-mixed-div.c   -Os  (internal compiler 
error: Segmentation fault)
+FAIL: c-c++-common/torture/complex-sign-mixed-sub.c   -Os  (internal compiler 
error: Segmentation fault)
+FAIL: gfortran.dg/bind-c-contiguous-1.f90   -Os  (internal compiler error: 
Segmentation fault)
+FAIL: gfortran.dg/bind-c-contiguous-4.f90   -Os  (internal compiler error: 
Segmentation fault)
+FAIL: gfortran.dg/minlocval_4.f90   -Os  (internal compiler error: 
Segmentation fault)

they all have a backtrace like this:

/home/jcmvbkbc/ws/tensilica/gcc/gcc/gcc/testsuite/gcc.dg/atomic/c11-atomic-exec-4.c:
 In function 'test_main_long_double_postinc':
/home/jcmvbkbc/ws/tensilica/gcc/gcc/gcc/testsuite/gcc.dg/atomic/c11-atomic-exec-4.c:73:1:
 internal compiler error: Segmentation fault
/home/jcmvbkbc/ws/tensilica/gcc/gcc/gcc/testsuite/gcc.dg/atomic/c11-atomic-exec-4.c:97:1:
 note: in expansion of macro 'TEST_FUNCS'                                       
                                       
0xf0493f crash_signal
        /home/jcmvbkbc/ws/tensilica/gcc/gcc/gcc/toplev.cc:319
0x7fcc65b98d5f ???
        ./signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
0x98cd63 lookup_page_table_entry
        /home/jcmvbkbc/ws/tensilica/gcc/gcc/gcc/ggc-page.cc:630                 
                                                                                
                                                
0x98cd63 ggc_set_mark(void const*)
        /home/jcmvbkbc/ws/tensilica/gcc/gcc/gcc/ggc-page.cc:1553
0x12b31bd gt_ggc_mx_hash_map_rtx_int_(void*)
        ./gt-xtensa.h:39
0xc19207 gt_ggc_mx_function(void*)                                              
                                                                                
                                                
        
/home/jcmvbkbc/ws/tensilica/gcc/builds/gcc-15-1382-g448482d3d5c2-xtensa-call0-le/gcc/gtype-desc.cc:1696
                                                                                
                 
0xc19207 gt_ggc_mx_function(void*)
        
/home/jcmvbkbc/ws/tensilica/gcc/builds/gcc-15-1382-g448482d3d5c2-xtensa-call0-le/gcc/gtype-desc.cc:1680
                                                                                
                 
0x85ffe7 gt_ggc_mx_lang_tree_node(void*)
        ./gt-c-c-decl.h:289 
0x86019c gt_ggc_mx_lang_tree_node(void*)
        ./gt-c-c-decl.h:381
0x860134 gt_ggc_mx_lang_tree_node(void*)                                        
                                                                                
                                                
        ./gt-c-c-decl.h:365
0x85fa04 gt_ggc_mx_lang_tree_node(void*)                                        
                                                                                
                                                
        ./gt-c-c-decl.h:259
0x86019c gt_ggc_mx_lang_tree_node(void*)                                        
                                                                                
                                                
        ./gt-c-c-decl.h:381
0x86063e gt_ggc_mx_lang_tree_node(void*)                                        
                                                                                
                                                
        ./gt-c-c-decl.h:204
0x8601be gt_ggc_mx_lang_tree_node(void*)                                        
                                                                                
                                                
        ./gt-c-c-decl.h:383
0x85fa04 gt_ggc_mx_lang_tree_node(void*)
        ./gt-c-c-decl.h:259                                                     
                                                                                
                                                
0x86019c gt_ggc_mx_lang_tree_node(void*)                                        
                                                                                
                                                
        ./gt-c-c-decl.h:381
0x8600ee gt_ggc_mx_lang_tree_node(void*)                                        
                                                                                
                                                
        ./gt-c-c-decl.h:360
0xc99b58 gt_ggc_mx_ipa_return_value_summary(void*)                              
                                                                                
                                                
        ./gt-ipa-prop.h:44
0xc99b58 gt_ggc_mx_ipa_return_value_summary(void*)                              
                                                                                
                                                
        ./gt-ipa-prop.h:39
0xc99b58 gt_ggc_mx(ipa_return_value_summary*&)
        ./gt-ipa-prop.h:62                                                      
                                                                                
                                                

-- 
Thanks.
-- Max

Reply via email to