Bug 97667 - [11 Regression] a bug in asm_operand_ok() recog.c:1801
Summary: [11 Regression] a bug in asm_operand_ok() recog.c:1801
Status: RESOLVED DUPLICATE of bug 97540
Alias: None
Product: gcc
Classification: Unclassified
Component: inline-asm (show other bugs)
Version: 11.0
: P3 normal
Target Milestone: 11.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2020-11-02 06:19 UTC by huntazhang
Modified: 2020-11-02 09:11 UTC (History)
3 users (show)

See Also:
Host:
Target: x86_64-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2020-11-02 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description huntazhang 2020-11-02 06:19:36 UTC
when i used gcc-11.0 compile linux kernel in
arch/x86/include/asm/checksum_64.h:171 trigger a bug 

here is compile source code argurment 
gcc -Wp,-MMD,net/core/.utils.o.d  -nostdinc -isystem /usr/lib/gcc/x86_64-linux-gnu/11.0.0/include -I../arch/x86/include -I./arch/x86/include/generated -I../include -I./include -I../arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I../include/uapi -I./include/generated/uapi -include ../include/linux/kconfig.h -include ../include/linux/compiler_types.h -D__KERNEL__ -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Wno-format-security -std=gnu89 -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mskip-rax-setup -mtune=generic -mno-red-zone -mcmodel=kernel -Wno-sign-compare -fno-asynchronous-unwind-tables -mindirect-branch=thunk-extern -mindirect-branch-register -fno-jump-tables -fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation -Wno-format-overflow -Wno-address-of-packed-member -O2 -fno-allow-store-data-races -Wframe-larger-than=2048 -fstack-protector-strong -Wno-unused-but-set-variable -Wimplicit-fallthrough -Wno-unused-const-variable -fomit-frame-pointer -Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-stringop-truncation -Wno-zero-length-bounds -Wno-array-bounds -Wno-stringop-overflow -Wno-restrict -Wno-maybe-uninitialized -fno-strict-overflow -fno-stack-check -fconserve-stack -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -fmacro-prefix-map=../= -fcf-protection=none -Wno-packed-not-aligned -I ../net/core -I ./net/core    -DKBUILD_MODFILE='"net/core/utils"' -DKBUILD_BASENAME='"utils"' -DKBUILD_MODNAME='"utils"' -c -o net/core/utils.o ../net/core/utils.c

here is gcc configure:

# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-linux-gnu/11.0.0/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../configure --enable-languages=c,c++ --program-suffix=-11 --program-prefix=x86_64-linux-gnu- --build=x86_64-linux-gnu --enable-multilib --enable-pugin --prefix=/usr
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.0 20201027 (experimental) (GCC) 

here is trigger  bug source code :
static inline unsigned add32_with_carry(unsigned a, unsigned b)
{
        asm("addl %2,%0\n\t"
            "adcl $0,%0"
            : "=r" (a)
            : "0" (a), "rm" (b));
        return a;
}

gcc-11.0 combine inline-asm 

(insn 43 84 44 5 (parallel [
            (set (reg:SI 126 [ a ])
                (asm_operands:SI ("addl %2,%0
	adcl $0,%0") ("=r") 0 [
                        (reg:SI 126 [ a ])
                        (not:SI (mem/j:SI (plus:DI (reg/v/f:DI 108 [ skb ])
                                    (const_int 136 [0x88])) [169 skb_7(D)->D.41008.csum+0 S4 A64]))
                    ]
                     [
                        (asm_input:SI ("0") ../arch/x86/include/asm/checksum_64.h:171)
                        (asm_input:SI ("rm") ../arch/x86/include/asm/checksum_64.h:171)
                    ]
                     [] ../arch/x86/include/asm/checksum_64.h:171))
            (clobber (reg:CC 17 flags))
        ]) "../arch/x86/include/asm/checksum_64.h":171:2 -1
     (expr_list:REG_UNUSED (reg:CC 17 flags)
        (nil)))

gcc-10 combine inline-asm 

(insn 43 84 44 5 (parallel [
            (set (reg:SI 126 [ a ])
                (asm_operands:SI ("addl %2,%0
	adcl $0,%0") ("=r") 0 [
                        (reg:SI 126 [ a ])
                        (reg:SI 127)
                    ]
                     [
                        (asm_input:SI ("0") ../arch/x86/include/asm/checksum_64.h:171)
                        (asm_input:SI ("rm") ../arch/x86/include/asm/checksum_64.h:171)
                    ]
                     [] ../arch/x86/include/asm/checksum_64.h:171))
            (clobber (reg:CC 17 flags))
        ]) "../arch/x86/include/asm/checksum_64.h":171:2 -1
     (expr_list:REG_DEAD (reg:SI 127)
        (expr_list:REG_UNUSED (reg:CC 17 flags)
            (nil))))


the difference between gcc10 and gcc 11 in asm_operand_ok() recog.c 

gcc-11 is 
case CT_MEMORY:
	    case CT_SPECIAL_MEMORY:
	      /* Every memory operand can be reloaded to fit.  */
	      result = result || memory_operand (extract_mem_from_operand (op),
						 VOIDmode);
	      break;

and gcc-10 is 

    case CT_MEMORY:
	    case CT_SPECIAL_MEMORY:
	      /* Every memory operand can be reloaded to fit.  */
	      result = result || memory_operand (op, VOIDmode);
	      break;

so in gcc-11 the insn  (not:SI (mem/j:SI (plus:DI (reg/v/f:DI 108 [ skb ])
                                    (const_int 136 [0x88])) [169 skb_7(D)->D.41008.csum+0 S4 A64])   
can not reocg  in lra_set_insn_recog_data()

here is the bactrace :
during RTL pass: reload
../net/core/utils.c: In function 'inet_proto_csum_replace_by_diff':
../net/core/utils.c:485:1: internal compiler error: in lra_set_insn_recog_data, at lra.c:1004
  485 | }
      | ^
0x6a0287 lra_set_insn_recog_data(rtx_insn*)
	../../gcc/lra.c:1004
0xc23bcf lra_get_insn_recog_data
	../../gcc/lra-int.h:488
0xc23bcf remove_scratches_1
	../../gcc/lra.c:2064
0xc23d17 lra_emit_move(rtx_def*, rtx_def*)
	../../gcc/lra.c:506
0xc361d6 curr_insn_transform
	../../gcc/lra-constraints.c:4523
0xc37666 lra_constraints(bool)
	../../gcc/lra-constraints.c:5123
0xc2426c lra(_IO_FILE*)
	../../gcc/lra.c:2415
0xbdfde1 do_reload
	../../gcc/ira.c:5529
0xbdfde1 execute
	../../gcc/ira.c:5715
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.

reported by TencentOS team
Comment 1 Jakub Jelinek 2020-11-02 08:20:06 UTC
I think we have a dup of this already.
Comment 2 Martin Liška 2020-11-02 08:36:45 UTC
Likely dup of PR97540.
Comment 3 Hongtao.liu 2020-11-02 08:38:16 UTC
(In reply to Martin Liška from comment #2)
> Likely dup of PR97540.

Yes, it should be.
Comment 4 Martin Liška 2020-11-02 09:05:02 UTC
Dup.

*** This bug has been marked as a duplicate of bug 97540 ***
Comment 5 huntazhang 2020-11-02 09:11:08 UTC
YES DUP.