public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Combine patch ping
@ 2024-04-01 19:28 Uros Bizjak
  2024-04-07  6:31 ` Uros Bizjak
  2024-04-07  8:00 ` Richard Biener
  0 siblings, 2 replies; 9+ messages in thread
From: Uros Bizjak @ 2024-04-01 19:28 UTC (permalink / raw)
  To: gcc-patches; +Cc: Segher Boessenkool, Jeff Law, Richard Biener

Hello!

I'd like to ping the
https://gcc.gnu.org/pipermail/gcc-patches/2024-March/647634.html
PR112560 P1 patch.

Thanks,
Uros.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Combine patch ping
  2024-04-01 19:28 Combine patch ping Uros Bizjak
@ 2024-04-07  6:31 ` Uros Bizjak
  2024-04-10 17:52   ` Segher Boessenkool
  2024-04-07  8:00 ` Richard Biener
  1 sibling, 1 reply; 9+ messages in thread
From: Uros Bizjak @ 2024-04-07  6:31 UTC (permalink / raw)
  To: gcc-patches; +Cc: Segher Boessenkool, Jeff Law, Richard Biener

On Mon, Apr 1, 2024 at 9:28 PM Uros Bizjak <ubizjak@gmail.com> wrote:

> I'd like to ping the
> https://gcc.gnu.org/pipermail/gcc-patches/2024-March/647634.html
> PR112560 P1 patch.

If there are no further comments, I plan to commit the referred patch
to the mainline on Wednesday. The latest version can be considered an
obvious patch that solves certain oversight in the original
implementation.

Thanks,
Uros.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Combine patch ping
  2024-04-01 19:28 Combine patch ping Uros Bizjak
  2024-04-07  6:31 ` Uros Bizjak
@ 2024-04-07  8:00 ` Richard Biener
  1 sibling, 0 replies; 9+ messages in thread
From: Richard Biener @ 2024-04-07  8:00 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: gcc-patches, Segher Boessenkool, Jeff Law



> Am 01.04.2024 um 21:28 schrieb Uros Bizjak <ubizjak@gmail.com>:
> 
> Hello!
> 
> I'd like to ping the
> https://gcc.gnu.org/pipermail/gcc-patches/2024-March/647634.html
> PR112560 P1 patch.

Ok.

Thanks,
Richard 

> Thanks,
> Uros.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Combine patch ping
  2024-04-07  6:31 ` Uros Bizjak
@ 2024-04-10 17:52   ` Segher Boessenkool
  2024-04-10 18:32     ` Uros Bizjak
  0 siblings, 1 reply; 9+ messages in thread
From: Segher Boessenkool @ 2024-04-10 17:52 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: gcc-patches, Jeff Law, Richard Biener

On Sun, Apr 07, 2024 at 08:31:38AM +0200, Uros Bizjak wrote:
> If there are no further comments, I plan to commit the referred patch
> to the mainline on Wednesday. The latest version can be considered an
> obvious patch that solves certain oversight in the original
> implementation.

This is never okay.  You cannot commit a patch without approval, *ever*.

That patch is also obvious -- obviously *wrong*, that is.  There are
big assumptions everywhere in the compiler how a CC reg can be used.
This violates that, as explained elsewhere.


Segher

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Combine patch ping
  2024-04-10 17:52   ` Segher Boessenkool
@ 2024-04-10 18:32     ` Uros Bizjak
  2024-04-11  6:15       ` Richard Biener
  2024-04-11 14:00       ` Segher Boessenkool
  0 siblings, 2 replies; 9+ messages in thread
From: Uros Bizjak @ 2024-04-10 18:32 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: gcc-patches, Jeff Law, Richard Biener

On Wed, Apr 10, 2024 at 7:56 PM Segher Boessenkool
<segher@kernel.crashing.org> wrote:
>
> On Sun, Apr 07, 2024 at 08:31:38AM +0200, Uros Bizjak wrote:
> > If there are no further comments, I plan to commit the referred patch
> > to the mainline on Wednesday. The latest version can be considered an
> > obvious patch that solves certain oversight in the original
> > implementation.
>
> This is never okay.  You cannot commit a patch without approval, *ever*.
>
> That patch is also obvious -- obviously *wrong*, that is.  There are
> big assumptions everywhere in the compiler how a CC reg can be used.
> This violates that, as explained elsewhere.

Can you please elaborate what is wrong with this concrete patch. The
part that the patch touches has several wrong assumptions, and the
fixed "???" comment just emphasizes that. I don't see what is wrong
with:

(define_insn "@pushfl<mode>2"
  [(set (match_operand:W 0 "push_operand" "=<")
    (unspec:W [(match_operand 1 "flags_reg_operand")]
          UNSPEC_PUSHFL))]
  "GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_CC"
  "pushf{<imodesuffix>}"
  [(set_attr "type" "push")
   (set_attr "mode" "<MODE>")])

it is just a push of the flags reg to the stack. If the push can't be
described in this way, then it is the middle end at fault, we can't
just change modes at will.

Feel free to revert the patch, I will unassign myself from the PR.

Uros.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Combine patch ping
  2024-04-10 18:32     ` Uros Bizjak
@ 2024-04-11  6:15       ` Richard Biener
  2024-04-11 14:00       ` Segher Boessenkool
  1 sibling, 0 replies; 9+ messages in thread
From: Richard Biener @ 2024-04-11  6:15 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: Segher Boessenkool, gcc-patches, Jeff Law

[-- Attachment #1: Type: text/plain, Size: 903 bytes --]

On Wed, 10 Apr 2024, Uros Bizjak wrote:

> On Wed, Apr 10, 2024 at 7:56 PM Segher Boessenkool
> <segher@kernel.crashing.org> wrote:
> >
> > On Sun, Apr 07, 2024 at 08:31:38AM +0200, Uros Bizjak wrote:
> > > If there are no further comments, I plan to commit the referred patch
> > > to the mainline on Wednesday. The latest version can be considered an
> > > obvious patch that solves certain oversight in the original
> > > implementation.
> >
> > This is never okay.  You cannot commit a patch without approval, *ever*.
> >
> > That patch is also obvious -- obviously *wrong*, that is.  There are
> > big assumptions everywhere in the compiler how a CC reg can be used.
> > This violates that, as explained elsewhere.
> 
> Can you please elaborate what is wrong with this concrete patch.

Better show a correct patch.  The interchanges in the last months
have not been constructive at all.

Richard.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Combine patch ping
  2024-04-10 18:32     ` Uros Bizjak
  2024-04-11  6:15       ` Richard Biener
@ 2024-04-11 14:00       ` Segher Boessenkool
  2024-04-11 14:53         ` Richard Biener
  2024-04-11 20:37         ` Uros Bizjak
  1 sibling, 2 replies; 9+ messages in thread
From: Segher Boessenkool @ 2024-04-11 14:00 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: gcc-patches, Jeff Law, Richard Biener

On Wed, Apr 10, 2024 at 08:32:39PM +0200, Uros Bizjak wrote:
> On Wed, Apr 10, 2024 at 7:56 PM Segher Boessenkool
> <segher@kernel.crashing.org> wrote:
> > This is never okay.  You cannot commit a patch without approval, *ever*.

This is the biggest issue, to start with.  It is fundamental.

> > That patch is also obvious -- obviously *wrong*, that is.  There are
> > big assumptions everywhere in the compiler how a CC reg can be used.
> > This violates that, as explained elsewhere.
> 
> Can you please elaborate what is wrong with this concrete patch.

The explanation of the patch is contradictory to how RTL works at all,
so it is just wrong.  It might even do something sane, but I didn't get
that far at all!

Write good email explanations, and a good proposed commit message.
Please.  It is the only one people can judge a patch.  Well, apart
from doing everything myself from first principles, ignoring everything
you said, just looking at the patch itself, but that is a hundred times
more work.  I don't do that.

> The
> part that the patch touches has several wrong assumptions, and the
> fixed "???" comment just emphasizes that. I don't see what is wrong
> with:
> 
> (define_insn "@pushfl<mode>2"
>   [(set (match_operand:W 0 "push_operand" "=<")
>     (unspec:W [(match_operand 1 "flags_reg_operand")]
>           UNSPEC_PUSHFL))]
>   "GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_CC"
>   "pushf{<imodesuffix>}"
>   [(set_attr "type" "push")
>    (set_attr "mode" "<MODE>")])

What does it even mean?  What is a flags:CC?  You always always always
need to say what is *in* the flags, if you want to use it as input
(which is what unspec does).  CC is weird like this.  Most targets do
not have distinct physical flags for every condition, only a few
conditions are "alive" at any point in the program!

> it is just a push of the flags reg to the stack. If the push can't be
> described in this way, then it is the middle end at fault, we can't
> just change modes at will.

But that is not what this describes: it operates on the flags register
in some unspecified way, and pushes the result of *that* to the stack.

(Stack pointer modification is not described here btw, should it be?  Is
that magically implemented by the backend some way, via type=push
perhaps?)


Segher

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Combine patch ping
  2024-04-11 14:00       ` Segher Boessenkool
@ 2024-04-11 14:53         ` Richard Biener
  2024-04-11 20:37         ` Uros Bizjak
  1 sibling, 0 replies; 9+ messages in thread
From: Richard Biener @ 2024-04-11 14:53 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: Uros Bizjak, gcc-patches, Jeff Law



> Am 11.04.2024 um 16:03 schrieb Segher Boessenkool <segher@kernel.crashing.org>:
> 
> On Wed, Apr 10, 2024 at 08:32:39PM +0200, Uros Bizjak wrote:
>>> On Wed, Apr 10, 2024 at 7:56 PM Segher Boessenkool
>>> <segher@kernel.crashing.org> wrote:
>>> This is never okay.  You cannot commit a patch without approval, *ever*.
> 
> This is the biggest issue, to start with.  It is fundamental.

I have approved the patch as you might have noticed.

Richard 

>>> That patch is also obvious -- obviously *wrong*, that is.  There are
>>> big assumptions everywhere in the compiler how a CC reg can be used.
>>> This violates that, as explained elsewhere.
>> 
>> Can you please elaborate what is wrong with this concrete patch.
> 
> The explanation of the patch is contradictory to how RTL works at all,
> so it is just wrong.  It might even do something sane, but I didn't get
> that far at all!
> 
> Write good email explanations, and a good proposed commit message.
> Please.  It is the only one people can judge a patch.  Well, apart
> from doing everything myself from first principles, ignoring everything
> you said, just looking at the patch itself, but that is a hundred times
> more work.  I don't do that.
> 
>> The
>> part that the patch touches has several wrong assumptions, and the
>> fixed "???" comment just emphasizes that. I don't see what is wrong
>> with:
>> 
>> (define_insn "@pushfl<mode>2"
>>  [(set (match_operand:W 0 "push_operand" "=<")
>>    (unspec:W [(match_operand 1 "flags_reg_operand")]
>>          UNSPEC_PUSHFL))]
>>  "GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_CC"
>>  "pushf{<imodesuffix>}"
>>  [(set_attr "type" "push")
>>   (set_attr "mode" "<MODE>")])
> 
> What does it even mean?  What is a flags:CC?  You always always always
> need to say what is *in* the flags, if you want to use it as input
> (which is what unspec does).  CC is weird like this.  Most targets do
> not have distinct physical flags for every condition, only a few
> conditions are "alive" at any point in the program!
> 
>> it is just a push of the flags reg to the stack. If the push can't be
>> described in this way, then it is the middle end at fault, we can't
>> just change modes at will.
> 
> But that is not what this describes: it operates on the flags register
> in some unspecified way, and pushes the result of *that* to the stack.
> 
> (Stack pointer modification is not described here btw, should it be?  Is
> that magically implemented by the backend some way, via type=push
> perhaps?)
> 
> 
> Segher

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Combine patch ping
  2024-04-11 14:00       ` Segher Boessenkool
  2024-04-11 14:53         ` Richard Biener
@ 2024-04-11 20:37         ` Uros Bizjak
  1 sibling, 0 replies; 9+ messages in thread
From: Uros Bizjak @ 2024-04-11 20:37 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: gcc-patches, Jeff Law, Richard Biener

On Thu, Apr 11, 2024 at 4:02 PM Segher Boessenkool
<segher@kernel.crashing.org> wrote:
>
> On Wed, Apr 10, 2024 at 08:32:39PM +0200, Uros Bizjak wrote:
> > On Wed, Apr 10, 2024 at 7:56 PM Segher Boessenkool
> > <segher@kernel.crashing.org> wrote:
> > > This is never okay.  You cannot commit a patch without approval, *ever*.
>
> This is the biggest issue, to start with.  It is fundamental.
>
> > > That patch is also obvious -- obviously *wrong*, that is.  There are
> > > big assumptions everywhere in the compiler how a CC reg can be used.
> > > This violates that, as explained elsewhere.
> >
> > Can you please elaborate what is wrong with this concrete patch.
>
> The explanation of the patch is contradictory to how RTL works at all,
> so it is just wrong.  It might even do something sane, but I didn't get
> that far at all!

The commit message explains the problem, the solution is explained in
the last couple of lines. Please see [1] for a more thorough
explanation of the problem.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112560#c13

> Write good email explanations, and a good proposed commit message.
> Please.  It is the only one people can judge a patch.  Well, apart
> from doing everything myself from first principles, ignoring everything
> you said, just looking at the patch itself, but that is a hundred times
> more work.  I don't do that.
>
> > The
> > part that the patch touches has several wrong assumptions, and the
> > fixed "???" comment just emphasizes that. I don't see what is wrong
> > with:
> >
> > (define_insn "@pushfl<mode>2"
> >   [(set (match_operand:W 0 "push_operand" "=<")
> >     (unspec:W [(match_operand 1 "flags_reg_operand")]
> >           UNSPEC_PUSHFL))]
> >   "GET_MODE_CLASS (GET_MODE (operands[1])) == MODE_CC"
> >   "pushf{<imodesuffix>}"
> >   [(set_attr "type" "push")
> >    (set_attr "mode" "<MODE>")])
>
> What does it even mean?  What is a flags:CC?  You always always always
> need to say what is *in* the flags, if you want to use it as input
> (which is what unspec does).  CC is weird like this.  Most targets do
> not have distinct physical flags for every condition, only a few
> conditions are "alive" at any point in the program!

From our previous discussion, we concluded that "use" means
cc-compared-to-0, but we also need a "copy" operation, to be able to
move CC reg around as a physical register (e.g. sahf, lahf, pushfl,
popfl instructions). This is a register that contains the state of the
CPU, described in [1] , not some RTL concept. The register is even
listed in i386.md:

(FLAGS_REG                   17)

with the "mode" that defines the value in the register more precisely.

[1] https://en.wikipedia.org/wiki/FLAGS_register

>
> > it is just a push of the flags reg to the stack. If the push can't be
> > described in this way, then it is the middle end at fault, we can't
> > just change modes at will.
>
> But that is not what this describes: it operates on the flags register
> in some unspecified way, and pushes the result of *that* to the stack.

No, the "use" is defined as cc-compared-to-0. The above is a "copy"
operation, the register that holds the state of the CPU is pushed on
the stack (and can be later popped from the stack to reload the saved
state). The pushfl instruction does not use the register in the sense
that it examines its contents.

> (Stack pointer modification is not described here btw, should it be?  Is
> that magically implemented by the backend some way, via type=push
> perhaps?)

Please see gen_pushfl() in i386.cc that emits the pattern:

#(insn:TI 5 2 6 2 (set (mem:DI (pre_dec:DI (reg/f:DI 7 sp)) [0  S8 A8])
#        (unspec:DI [
#                (reg:CC 17 flags)
#            ] UNSPEC_PUSHFL)) "flags.c":3:10 70 {pushfldi2}
#     (expr_list:REG_DEAD (reg:CC 17 flags)
#        (nil)))
       pushfq          # 5     [c=4 l=1]  pushfldi2

Uros.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-04-11 20:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-01 19:28 Combine patch ping Uros Bizjak
2024-04-07  6:31 ` Uros Bizjak
2024-04-10 17:52   ` Segher Boessenkool
2024-04-10 18:32     ` Uros Bizjak
2024-04-11  6:15       ` Richard Biener
2024-04-11 14:00       ` Segher Boessenkool
2024-04-11 14:53         ` Richard Biener
2024-04-11 20:37         ` Uros Bizjak
2024-04-07  8:00 ` Richard Biener

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).