Hi Suwa-san,

On Thu, Apr 24, 2025 at 12:07 AM Takayuki 'January June' Suwa
<jjsuwa_sys3...@yahoo.co.jp> wrote:
>
> Recent gcc versions tend to convert constants for which
> TARGET_LEGITIMATE_CONSTANT_P returns false into references to literal pool
> entries during the RTL instruction combination pass for pattern matching.
>
> For example, the following pattern will currently never match unless either
> TARGET_CONST16 or TARGET_AUTO_LITPOOLS is enabled:
>
>    [(set (match_operand:SI 0 "register_operand" "=a")
>         (match_operator:SI 2 "boolean_operator"
>                 [(match_operand:SI 1 "register_operand" "r")
>                  (const_int -2147483648)]))]
>
> because INT_MIN will be put into literal pool during the combination.
>
> This patch avoids the above problem in the way described in the title.
>
> gcc/ChangeLog:
>
>         * config/xtensa/xtensa.cc (xtensa_legitimate_constant_p):
>         Add a logical OR with !xtensa_split1_finished_p() to the condition
>         that returns true to include the RTL instruction combination pass.
>         (xtensa_emit_move_sequence): Make its behavior consistent with
>         the above change.
> ---
>   gcc/config/xtensa/xtensa.cc | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)

This change results in the following regression in the gcc testsuite:

-PASS: gcc.c-torture/execute/pr68328.c   -O2 -flto -fuse-linker-plugin
-fno-fat-lto-objects  (test for excess errors)
-PASS: gcc.c-torture/execute/pr68328.c   -O2 -flto -fuse-linker-plugin
-fno-fat-lto-objects  execution test
+FAIL: gcc.c-torture/execute/pr68328.c   -O2 -flto -fuse-linker-plugin
-fno-fat-lto-objects  (internal compiler error: in
extract_constrain_insn, at recog.cc:2783)
+FAIL: gcc.c-torture/execute/pr68328.c   -O2 -flto -fuse-linker-plugin
-fno-fat-lto-objects  (test for excess errors)

with the following diagnostics:

/home/jcmvbkbc/ws/tensilica/gcc/gcc/gcc/testsuite/gcc.c-torture/execute/pr68328.c:
In function 'bar':
/home/jcmvbkbc/ws/tensilica/gcc/gcc/gcc/testsuite/gcc.c-torture/execute/pr68328.c:16:1:
error: unrecognizable insn:
(insn 7 4 8 2 (parallel [
           (asm_operands/v ("") ("") 0 [
                   (const_int 1193046 [0x123456])
                   (const_int 0 [0])
               ]
                [
                   (asm_input:SI ("g")
/home/jcmvbkbc/ws/tensilica/gcc/gcc/gcc/testsuite/gcc.c-torture/execute/pr68328.c:13)
                   (asm_input:SI ("g")
/home/jcmvbkbc/ws/tensilica/gcc/gcc/gcc/testsuite/gcc.c-torture/execute/pr68328.c:13)
               ]
                []
/home/jcmvbkbc/ws/tensilica/gcc/gcc/gcc/testsuite/gcc.c-torture/execute/pr68328.c:13)
           (clobber (mem:BLK (scratch) [0  A8]))
       ]) 
"/home/jcmvbkbc/ws/tensilica/gcc/gcc/gcc/testsuite/gcc.c-torture/execute/pr68328.c":13:3
-1
    (nil))
during RTL pass: reload
/home/jcmvbkbc/ws/tensilica/gcc/gcc/gcc/testsuite/gcc.c-torture/execute/pr68328.c:16:1:
internal compiler error: in extract_constrain_insn, at recog.cc:2783
0x1b1de5f internal_error(char const*, ...)
       /home/jcmvbkbc/ws/tensilica/gcc/gcc/gcc/diagnostic-global-context.cc:517
0x8242ea fancy_abort(char const*, int, char const*)
       /home/jcmvbkbc/ws/tensilica/gcc/gcc/gcc/diagnostic.cc:1749
0x6c3448 _fatal_insn(char const*, rtx_def const*, char const*, int, char const*)
       /home/jcmvbkbc/ws/tensilica/gcc/gcc/gcc/rtl-error.cc:108
0x6c3464 _fatal_insn_not_found(rtx_def const*, char const*, int, char const*)
       /home/jcmvbkbc/ws/tensilica/gcc/gcc/gcc/rtl-error.cc:116
0x6c1ff9 extract_constrain_insn(rtx_insn*)
       /home/jcmvbkbc/ws/tensilica/gcc/gcc/gcc/recog.cc:2783
0xc20fd7 check_rtl
       /home/jcmvbkbc/ws/tensilica/gcc/gcc/gcc/lra.cc:2202
0xc2517b lra(_IO_FILE*, int)
       /home/jcmvbkbc/ws/tensilica/gcc/gcc/gcc/lra.cc:2636
0xbdbe77 do_reload
       /home/jcmvbkbc/ws/tensilica/gcc/gcc/gcc/ira.cc:5987
0xbdbe77 execute
       /home/jcmvbkbc/ws/tensilica/gcc/gcc/gcc/ira.cc:6175

-- 
Thanks.
-- Max

Reply via email to