From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 04E36386F831; Thu, 28 May 2020 12:34:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 04E36386F831 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1590669275; bh=sjqTQsHN9cDHkTHzeIV8hYEVF8LzoyQ1vJLQS5buUJE=; h=From:To:Subject:Date:From; b=p9dZVDggLKi1pGsbuG/61EnkcIIdF5H/Ug9ikmRxFWwqoG7CbUEpmAoAIocUBBrFl P2Nqw2vvGdr3sG17lF3+RKNxYWmATafZmaPJwwE1p4nmdAb5bku7J6IHwrDvMgr6kE pi7aec68r4ylpzksMpbTrAfz4gAt1Vy8BJGiUYv8= From: "xuemaosheng at huawei dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/95382] New: [haifa-sched][DO_PREDICATION] execution test: wrong scheduling result. Date: Thu, 28 May 2020 12:34:34 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 7.3.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: xuemaosheng at huawei dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: 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: Thu, 28 May 2020 12:34:35 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95382 Bug ID: 95382 Summary: [haifa-sched][DO_PREDICATION] execution test: wrong scheduling result. Product: gcc Version: 7.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: xuemaosheng at huawei dot com Target Milestone: --- Created attachment 48626 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D48626&action=3Dedit the source file After we enable the schedule DO_PREDICATION, we get wrong scheduling result= in sched2 pass. The key dump is shown as following=EF=BC=9A .......(Unimportant things) ;; | 93 | 15 | a20=3Dsxn([a19])=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ;; | 94 | 10 | t2=3Da20=3D=3D0=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ;; | 95 | 9 | pc=3D{(t2!=3D0)?L107:pc} jump_insn1=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ;; | 159 | 10 | a21=3D0xffffffffffff8000=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ;; | 98 | 9 | t0=3Da23!=3Da21=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ;; | 99 | 8 | pc=3D{(t0=3D=3D0)?L173:pc} jump_insn2=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ;; | 105 | 7 | a22=3Da23/a20 div_insn=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ;; | 106 | 1 | a23=3Dsxn(a22)=20=20 .......(Unimportant things)=20=20=20=20 ;; --- EBB Dependences --- from bb4 to bb6=20 ;; insn code bb dep prio cost reservation .......(Unimportant things) ;; 93 94 4 4 15 1 : 105(t,1) 99(a,0) 94(t,5)=20= =20=20=20=20=20=20=20=20=20 ;; 94 1645 4 1 10 1 : 106(t,1) 95(t,1)=20=20=20=20= =20=20=20 ;; 95 139 4 13 9 1 : 106(c,1) 99(a,1)nm=20=20=20= =20=20=20=20=20=20=20=20=20=20 ;; 159 129 5 0 10 1 : 98(t,1)=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20 ;; 98 1650 5 2 9 1 : 105(t,1) 106(t,1)m 99(t,1) ;; 99 139 5 15 8 1 : 105(c,1) 106(c,1)=20=20=20=20= =20=20=20=20=20=20=20=20=20=20 ;; 105 37 6 4 7 1 : 106(t,6)m=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ;; 106 94 6 6 1 1 :=20=20 .......(Unimportant things)=20=20=20=20=20=20=20=20=20 When we enable the schedule DO_PREDICATION, we can produce conditional=20 execution insn. Since insn 98(t0=3Da23!=3Da21) doesn't have dependence with jump_insn1 95 (pc=3D{(t2!=3D0)?L107:pc}), so insn 98 can issue before jump_insn1 95. And insn 93 (a20=3Dsxn([a19])) can also issue before jump_insn1 95. After that, insn 105(a22=3Da23/a20) can become conditional execution insn s= hown=20 as following dump: ;; 51--> 93 a20=3Dsxn([a19]) :=20=20=20= =20=20=20=20=20=20 rescanning insn with uid =3D 105.=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20 ;; dependencies resolved: insn 105 predicated=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ;; Ready-->Q: insn 105: queued for 1 cycles (change queue index). ;; tick updated: insn 105 into queue with cost=3D1=20=20 After predicating, insn 105 have become : [t0]a22=3Da23/a20 ;; 52--> 105 (t0) a22=3Da23/a20 :=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20 ;; Ready list (t =3D 52): .......(Unimportant things)=20 ;; Ready list (t =3D 56): 94:50:prio=3D10=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 [52;56]:94=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ;; 56--> 94 t2=3Da20=3D=3D0 :=20=20= =20=20=20=20=20=20=20 .......(Unimportant things)=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ;; Ready list (t =3D 57): 95:51:prio=3D9=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 [56;57]:95=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ;; 57--> 95 pc=3D{(t2!=3D0)?L107:pc} : finally, insn 105([t0]a22=3Da23/a20) is issued before insn 95 (pc=3D{(t2!=3D0)?L107:pc}). However, insn 95 has decided reg a20 is valid not. In this case, a20 is 0, so we get division by 0 error. The scheduling result is shown as the following: tstneq@ags t0, a23, a21 # [28] # 98 .... l16si@agl a20, a19, 0 # [51] # 93 .... [t0] quos@sau a22, a23, a20 # [52] # 105 tsteqi@sau t2, a20, 0 # [53] # 94 [t2] b@pcu .L5, 1 # [54] # 95 [!t0] b@pcu .L28, 0 # [55] # 99 ...... Insn 105 (div_insn)should not be issued before insn 95(jump_insn1). Note=EF=BC=9A This ebb is 3 basic-blocks. Since supporting DO_PREDICATION target is little, it's difficult to recurre= nt in other target. How can we solve the problem?=