From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5FA8A39878C1; Fri, 15 Jan 2021 16:52:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5FA8A39878C1 From: "crazylht at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/98694] [11 Regression] GCC produces incorrect code for loops with -O3 for skylake-avx512 and icelake-server Date: Fri, 15 Jan 2021 16:52:01 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: crazylht at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Jan 2021 16:52:02 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98694 --- Comment #3 from Hongtao.liu --- (In reply to Hongtao.liu from comment #1) > cprop hardreg change >=20 > (insn 457 499 460 33 (set (reg:SI 39 r11 [orig:86 _11 ] [86]) > (reg:SI 37 r9 [orig:86 _11 ] [86])) "test.c":29:36 75 > {*movsi_internal} > (expr_list:REG_DEAD (reg:SI 37 r9 [orig:86 _11 ] [86]) > (nil))) >=20 > to >=20 > (insn 457 499 460 33 (set (reg:SI 39 r11 [orig:86 _11 ] [86]) > (reg:SI 22 xmm2 [orig:86 _11 ] [86])) "test.c":29:36 75 > {*movsi_internal} > (expr_list:REG_DEAD (reg:SI 22 xmm2 [orig:86 _11 ] [86]) > (nil))) >=20 > since it thought the lower 32bit of r9 and xmm2 is the same? >=20 > but with xmm2 defined as >=20 > kmovw %k0, %edi # 69 [c=3D4 l=3D4] *movhi_internal/6 > kmovd %k0, %edx # 487 [c=3D4 l=3D3] *movsi_internal/16 > vmovd %edi, %xmm2 # 489 >=20 > the bit16-32 is clear with kmovw(note k0 is equal to r9 with SImode, it's > var_6 in source code) >=20 > (insn 69 68 70 12 (set (reg:HI 5 di [orig:96 _52 ] [96]) > (reg:HI 68 k0 [orig:82 var_6.0_1 ] [82])) "test.c":21:23 76 > {*movhi_internal} > (nil)) >=20 > (insn 489 75 78 12 (set (reg:SI 22 xmm2 [297]) > (reg:SI 5 di [orig:96 _52 ] [96])) 75 {*movsi_internal} > (nil)) It seems to be be handled here. cut from copy_value in regcprop.c: ---- /* If SRC had been assigned a mode narrower than the copy, we can't link DEST into the chain, because not all of the pieces of the copy came from oldest_regno. */ else if (sn > hard_regno_nregs (sr, vd->e[sr].mode)) return; ---- here we have %edi set as HImode, but use as SImode and be copied to %xmm2, = but the condition failed to check this beacuase both SImode and HImode has nreg= s as 1, since the upper part could be garbage, it can't link DEST into the chain. kmovw %k0, %edi # 69 [c=3D4 l=3D4] *movhi_internal/6 <= ----HI kmovd %k0, %edx # 487 [c=3D4 l=3D3] *movsi_internal/16=20 vmovd %edi, %xmm2 # 489 [c=3D4 l=3D6] *movsi_internal/13 <= ----SI sall $16, %edx # 73 [c=3D4 l=3D3] *ashlsi3_1/0 kmovw %k0, %r8d # 74 [c=3D4 l=3D5] *zero_extendhisi2/1 vpshuflw $0, %xmm2, %xmm0 # 78 [c=3D4 l=3D5]=20 *vec_dupv4hi/1 orl %edx, %r8d # 75 [c=3D4 l=3D3] *iorsi_1/0 testw %di, %di # 82 [c=3D4 l=3D3] *cmphi_ccno_1/0 jle .L52 # 83 [c=3D12 l=3D6] *jcc kmovd %k0, %r9d # 85 [c=3D4 l=3D4] *movsi_internal/16 <= ----SI testl %r9d, %r9d # 88 [c=3D4 l=3D3] *cmpsi_ccno_1/0=