public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "xry111 at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
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 07:16:46 +0000	[thread overview]
Message-ID: <bug-111334-4-bGJPNVhTR8@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-111334-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111334

--- Comment #15 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
(In reply to chenglulu from comment #13)
> (In reply to Xi Ruoyao from comment #12)
> > (In reply to chenglulu from comment #11)
> > > (In reply to Xi Ruoyao from comment #10)
> > > > (In reply to Xi Ruoyao from comment #9)
> > > > 
> > > > >  (define_insn "<optab>di3_fake"
> > > > >    [(set (match_operand:DI 0 "register_operand" "=r,&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"))))]
> > > > > -  ""
> > > > > +	(if_then_else
> > > > > +	  (and (eq (match_operand:DI 1 "register_operand" "r,r,0")
> > > > > +		   (sign_extend:DI (subreg:SI (match_dup 1) 0)))
> > > > > +	       (eq (match_operand:DI 2 "register_operand" "r,r,r")
> > > > > +		   (sign_extend:DI (subreg:SI (match_dup 2) 0))))
> > > > > +	  (sign_extend:DI
> > > > > +	    (any_div:SI (subreg:SI (match_dup 1) 0)
> > > > > +			(subreg:SI (match_dup 2) 0)))
> > > > > +	  (unspec:DI [(const_int 0)] UNSPEC_BAD_DIVW)))]
> > > > 
> > > > With this the compiler will still believe all bad {div,mod}.w{,u}
> > > 
> > > I think this is already defined as UNSPEC. Isn’t the simpler the logic, the
> > > better?
> > 
> > Yes, I think we should just use 4 different UNSPEC_ values and the simple
> > version.  But I've not find a way to use 4 different UNSPEC_ values in the
> > RTL template except duplicating everything 4 times...
> 
> I still have a question that I don't quite understand, that is, why that the
> four generated strings are equivalent when using an UNSPEC name? My template
> names are different, and they will not be automatically matched during
> optimization.???

Oh I get it, you mean

 (define_insn "<optab>di3_fake"
   [(set (match_operand:DI 0 "register_operand" "=r,&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"))))]
+         (unspec:DI [(any_div:DI
+                       (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 ("<insn>.w<u>\t%0,%1,%2", operands);

Good idea! I think it's better than my stupid hacks :).

I'd been thinking about:

 (define_insn "<optab>di3_fake"
   [(set (match_operand:DI 0 "register_operand" "=r,&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"))))]
+         (unspec:DI [(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 ("<insn>.w<u>\t%0,%1,%2", operands);

and this is just wrong.

  parent reply	other threads:[~2023-09-08  7:16 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-08  3:17 [Bug c/111334] New: " chenglulu at loongson dot cn
2023-09-08  3:20 ` [Bug c/111334] " chenglulu at loongson dot cn
2023-09-08  3:26 ` chenglulu at loongson dot cn
2023-09-08  3:52 ` chenglulu at loongson dot cn
2023-09-08  3:58 ` [Bug target/111334] " pinskia at gcc dot gnu.org
2023-09-08  4:39 ` xry111 at gcc dot gnu.org
2023-09-08  4:45 ` xry111 at gcc dot gnu.org
2023-09-08  4:48 ` [Bug target/111334] [14 regression] " xry111 at gcc dot gnu.org
2023-09-08  6:02 ` chenglulu at loongson dot cn
2023-09-08  6:18 ` chenglulu at loongson dot cn
2023-09-08  6:39 ` xry111 at gcc dot gnu.org
2023-09-08  6:47 ` xry111 at gcc dot gnu.org
2023-09-08  6:53 ` chenglulu at loongson dot cn
2023-09-08  6:58 ` xry111 at gcc dot gnu.org
2023-09-08  7:03 ` chenglulu at loongson dot cn
2023-09-08  7:04 ` xry111 at gcc dot gnu.org
2023-09-08  7:16 ` xry111 at gcc dot gnu.org [this message]
2023-09-09  7:16 ` chenglulu at loongson dot cn
2023-09-09  7:47 ` xry111 at gcc dot gnu.org
2023-09-09  8:24 ` chenglulu at loongson dot cn
2023-09-09  9:52 ` xry111 at gcc dot gnu.org
2023-09-14  1:06 ` cvs-commit at gcc dot gnu.org
2023-09-14  1:17 ` chenglulu at loongson dot cn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-111334-4-bGJPNVhTR8@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).