From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 07EC13858D1E; Fri, 8 Sep 2023 06:02:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 07EC13858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694152923; bh=r6N8CyM5sbr1wNz+MbCZczY37R+u+tpAU3NbVvEcsYY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=GLrFUSF8Ccy47IzCTn3nIO0TDNZljDSqKvTvip39wxVZNg2tckXo5v/kSbFifoRnt fOUJXUfG3UowDA/wG1ueayK0llBV6Hi8CH/1XvaQdq85K86ru1KBhaNNnFTlZ+ufRx 65KoCggljdditCkjEBgfxM51Y2DOGy5sQewOOATs= From: "chenglulu at loongson dot cn" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/111334] [14 regression] ICE is reported during the combine pass optimization Date: Fri, 08 Sep 2023 06:02: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: 14.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: chenglulu at loongson dot cn X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 14.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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111334 --- Comment #7 from chenglulu --- (In reply to Xi Ruoyao from comment #6) > (In reply to Xi Ruoyao from comment #5) > > (In reply to chenglulu from comment #3) > > > This involves the template di3_fake: > > > (define_insn "di3_fake" > > > [(set (match_operand:DI 0 "register_operand" "=3Dr,&r,&r") > > > (sign_extend:DI > > > (any_div:SI (match_operand:DI 1 "register_operand" "r,r,0") > > > (match_operand:DI 2 "register_operand" "r,r,r")= )))] > > > "" > > > { > > > return loongarch_output_division (".w\t%0,%1,%2", operands= ); > > > } > > > [(set_attr "type" "idiv") > > > (set_attr "mode" "SI") > > > (set (attr "enabled") > > > (if_then_else > > > (match_test "!!which_alternative =3D=3D loongarch_check_zero_= div_p()") > > > (const_string "yes") > > > (const_string "no")))]) > > >=20 > > >=20 > > > I think there is a problem with the implementation of this template.= =20 > > > First, the instructions generated in the template are [u]div.w[u], et= c. The > > > description of such instructions in the instruction manual is that if= the > > > upper 32 bits are not extended by the 31st bit sign then the result is > > > uncertain. > >=20 > > I think this reason alone makes the pattern looks very wrong. > >=20 > > I'll take a look... >=20 > Hmm, I guess we should just make di3_fake an UNSPEC because there is no w= ay > to use div.w and its friends out of 3. I agree with your idea, so I tried changing it to something like this.Do you think it's okay for me to change like this? (define_insn "di3_fake" [(set (match_operand:DI 0 "register_operand" "=3Dr,&r,&r") (sign_extend:DI (unspec:SI [(any_div:SI (match_operand:DI 1 "register_operand" "r,r,0") (match_operand:DI 2 "register_operand" "r,r,r"))] UNSPEC_ANY_DIV)))] "" { return loongarch_output_division (".w\t%0,%1,%2", operands); } [(set_attr "type" "idiv") (set_attr "mode" "SI") (set (attr "enabled") (if_then_else (match_test "!!which_alternative =3D=3D loongarch_check_zero_div_p(= )") (const_string "yes") (const_string "no")))])=