All of lore.kernel.org
 help / color / mirror / Atom feed
* Trying to understand linearized output
@ 2017-03-12 14:11 Dibyendu Majumdar
  2017-03-12 17:10 ` Luc Van Oostenryck
  0 siblings, 1 reply; 6+ messages in thread
From: Dibyendu Majumdar @ 2017-03-12 14:11 UTC (permalink / raw)
  To: Linux-Sparse

Hi

I am trying to understand following.

The function in question is shown below and is compiled as part of a
larger program with other functions.

/* find the next object in the tree */
void           *
AVLTree_FindNext(AVLTree * tree, void *currnode)
{
 AVLNode        *current;
 current = (AVLNode *) currnode;
 if (current) {
  --current;
  if (current->right) {
   current = current->right;
   while (current->left != NULL)
    current = current->left;
  } else {
   AVLNode        *p;
   p = current;
   current = p->parent;
   while (current) {
    if (current->right == p) {
     p = current;
     current = current->parent;
    } else
     break;
   }
  }
 }
 if (current)
  return (void *) (current + 1);
 else
  return NULL;
}

The linearized output is:

AVLTree_FindNext:
.L125:
 <entry-point>
 ptrcast.64  %r333 <- (64) %arg2
 phisrc.64   %phi98(current) <- %r333
 br          %r333, .L126, .L127
.L126:
 add.64      %r336 <- %r333, $-32
 load.64     %r338 <- -16[%r333]
 br          %r338, .L128, .L129
.L128:
 phisrc.64   %phi108(current) <- %r338
 br          .L133
.L133:
 phi.64      %r341(current) <- %phi108(current), %phi109(current)
 load.64     %r342 <- 8[%r341(current)]
 phisrc.64   %phi99(current) <- %r341(current)
 br          %r342, .L130, .L127
.L130:
 phisrc.64   %phi109(current) <- %r342
 br          .L133
.L129:
 load.64     %r348(current) <- -32[%r333]
 phisrc.64   %phi104(current) <- %r348(current)
 phisrc.64   %phi112(p) <- %r336
 br          .L138
.L138:
 phi.64      %r349(current) <- %phi104(current), %phi105(current)
 phisrc.64   %phi100(current) <- %r349(current)
 br          %r349(current), .L135, .L127
.L135:
 load.64     %r351 <- 16[%r349(current)]
 phi.64      %r352 <- %phi112(p), %phi113(p)
 seteq.32    %r353 <- %r351, %r352
 phisrc.64   %phi101(current) <- %r349(current)
 br          %r353, .L139, .L127
.L139:
 load.64     %r356 <- 0[%r349(current)]
 phisrc.64   %phi105(current) <- %r356
 phisrc.64   %phi113(p) <- %r349(current)
 br          .L138
.L127:
 phi.64      %r357(current) <- %phi98(current), %phi99(current),
%phi100(current), %phi101(current)
 br          %r357(current), .L142, .L143
.L142:
 add.64      %r359 <- %r357(current), $32
 cast.64     %r360 <- (64) %r359
 phisrc.64   %phi95(return) <- %r360
 br          .L144
.L143:
 phisrc.64   %phi96(return) <- $0
 br          .L144
.L144:
 phi.64      %r361 <- %phi95(return), %phi96(return)
 ret.64      %r361


My question is:

phisrc.64   %phi98(current) <- %r333

The phi98 above is presumably referencing a pseudo which has number
98. But this is not part of this function, so I am confused. Does this
look right?

Thanks and Regards
Dibyendu

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

* Re: Trying to understand linearized output
  2017-03-12 14:11 Trying to understand linearized output Dibyendu Majumdar
@ 2017-03-12 17:10 ` Luc Van Oostenryck
  2017-03-12 17:15   ` Dibyendu Majumdar
  0 siblings, 1 reply; 6+ messages in thread
From: Luc Van Oostenryck @ 2017-03-12 17:10 UTC (permalink / raw)
  To: Dibyendu Majumdar; +Cc: Linux-Sparse

On Sun, Mar 12, 2017 at 02:11:37PM +0000, Dibyendu Majumdar wrote:
> ...
>
> My question is:
> 
> phisrc.64   %phi98(current) <- %r333
> 
> The phi98 above is presumably referencing a pseudo which has number
> 98. But this is not part of this function, so I am confused. Does this
> look right?

I didn't checked all the details by it looks right.

The %phi98 is not referencing a pseudo which has the number 98.
It is a pseudo numbered 98 and which is of type PSEUDO_PHI.
Those kind of pseudos are exclusively created by 'phisrc' instructions
and used by 'phi' instructions.
Here this %phi98 is used by the phi instructions at block .L127

These 'phi' instructions are the core of the SSA representation of
intermediate code. If needed Wikipedia gives a good introduction:
	 https://en.wikipedia.org/wiki/Static_single_assignment_form

-- Luc Van Oostenryck

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

* Re: Trying to understand linearized output
  2017-03-12 17:10 ` Luc Van Oostenryck
@ 2017-03-12 17:15   ` Dibyendu Majumdar
  2017-03-12 17:20     ` Luc Van Oostenryck
  0 siblings, 1 reply; 6+ messages in thread
From: Dibyendu Majumdar @ 2017-03-12 17:15 UTC (permalink / raw)
  To: Luc Van Oostenryck; +Cc: Linux-Sparse

On 12 March 2017 at 17:10, Luc Van Oostenryck
<luc.vanoostenryck@gmail.com> wrote:
> On Sun, Mar 12, 2017 at 02:11:37PM +0000, Dibyendu Majumdar wrote:
>> ...
>>
>> My question is:
>>
>> phisrc.64   %phi98(current) <- %r333
>>
>> The phi98 above is presumably referencing a pseudo which has number
>> 98. But this is not part of this function, so I am confused. Does this
>> look right?
>
> I didn't checked all the details by it looks right.
>
> The %phi98 is not referencing a pseudo which has the number 98.
> It is a pseudo numbered 98 and which is of type PSEUDO_PHI.
> Those kind of pseudos are exclusively created by 'phisrc' instructions
> and used by 'phi' instructions.
> Here this %phi98 is used by the phi instructions at block .L127
>
> These 'phi' instructions are the core of the SSA representation of
> intermediate code. If needed Wikipedia gives a good introduction:
>          https://en.wikipedia.org/wiki/Static_single_assignment_form


Thanks. I am familiar with phi instructions in LLVM, but the phisrc
instructions in Sparse are new to me.

Regards
Dibyendu

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

* Re: Trying to understand linearized output
  2017-03-12 17:15   ` Dibyendu Majumdar
@ 2017-03-12 17:20     ` Luc Van Oostenryck
  2017-03-12 18:00       ` Dibyendu Majumdar
  0 siblings, 1 reply; 6+ messages in thread
From: Luc Van Oostenryck @ 2017-03-12 17:20 UTC (permalink / raw)
  To: Dibyendu Majumdar; +Cc: Linux-Sparse

On Sun, Mar 12, 2017 at 05:15:54PM +0000, Dibyendu Majumdar wrote:
> On 12 March 2017 at 17:10, Luc Van Oostenryck
> <luc.vanoostenryck@gmail.com> wrote:
> > On Sun, Mar 12, 2017 at 02:11:37PM +0000, Dibyendu Majumdar wrote:
> >> ...
> >>
> >> My question is:
> >>
> >> phisrc.64   %phi98(current) <- %r333
> >>
> >> The phi98 above is presumably referencing a pseudo which has number
> >> 98. But this is not part of this function, so I am confused. Does this
> >> look right?
> >
> > I didn't checked all the details by it looks right.
> >
> > The %phi98 is not referencing a pseudo which has the number 98.
> > It is a pseudo numbered 98 and which is of type PSEUDO_PHI.
> > Those kind of pseudos are exclusively created by 'phisrc' instructions
> > and used by 'phi' instructions.
> > Here this %phi98 is used by the phi instructions at block .L127
> >
> > These 'phi' instructions are the core of the SSA representation of
> > intermediate code. If needed Wikipedia gives a good introduction:
> >          https://en.wikipedia.org/wiki/Static_single_assignment_form
> 
> 
> Thanks. I am familiar with phi instructions in LLVM, but the phisrc
> instructions in Sparse are new to me.

Good. I wasn't sure.

Those phisrc are unimportant, you can consider them as a kind of 'move'
which is only but systematically used for each pseudo feeded to a phi
instruction. They ahev no special semantic, they just make some things
little bit easier for sparse.

Luc

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

* Re: Trying to understand linearized output
  2017-03-12 17:20     ` Luc Van Oostenryck
@ 2017-03-12 18:00       ` Dibyendu Majumdar
  2017-03-12 19:27         ` Luc Van Oostenryck
  0 siblings, 1 reply; 6+ messages in thread
From: Dibyendu Majumdar @ 2017-03-12 18:00 UTC (permalink / raw)
  To: Luc Van Oostenryck; +Cc: Linux-Sparse

On 12 March 2017 at 17:20, Luc Van Oostenryck
<luc.vanoostenryck@gmail.com> wrote:
> On Sun, Mar 12, 2017 at 05:15:54PM +0000, Dibyendu Majumdar wrote:
>> On 12 March 2017 at 17:10, Luc Van Oostenryck
>> <luc.vanoostenryck@gmail.com> wrote:
>> > On Sun, Mar 12, 2017 at 02:11:37PM +0000, Dibyendu Majumdar wrote:
>> >> ...
>> >>
>> >> My question is:
>> >>
>> >> phisrc.64   %phi98(current) <- %r333
>> >>
>> >> The phi98 above is presumably referencing a pseudo which has number
>> >> 98. But this is not part of this function, so I am confused. Does this
>> >> look right?
>> >
>> > I didn't checked all the details by it looks right.
>> >
>> > The %phi98 is not referencing a pseudo which has the number 98.
>> > It is a pseudo numbered 98 and which is of type PSEUDO_PHI.
>> > Those kind of pseudos are exclusively created by 'phisrc' instructions
>> > and used by 'phi' instructions.
>> > Here this %phi98 is used by the phi instructions at block .L127
>> >
>> > These 'phi' instructions are the core of the SSA representation of
>> > intermediate code. If needed Wikipedia gives a good introduction:
>> >          https://en.wikipedia.org/wiki/Static_single_assignment_form
>>
>>
>> Thanks. I am familiar with phi instructions in LLVM, but the phisrc
>> instructions in Sparse are new to me.
>
> Good. I wasn't sure.
>
> Those phisrc are unimportant, you can consider them as a kind of 'move'
> which is only but systematically used for each pseudo feeded to a phi
> instruction. They ahev no special semantic, they just make some things
> little bit easier for sparse.
>

I got confused by the numbering initially as I was expecting all
pseudos within a single function to be numbered sequentially.

So I should just read following :

phisrc.64   %phi98(current) <- %r333

As:

%phi98(current) = %r333

And 98 just happens to be the identifier for the pseudo, and 'phi' is
just to help the reader know that the value will go into a phi
instruction later. Is that correct?

Regards
Dibyendu

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

* Re: Trying to understand linearized output
  2017-03-12 18:00       ` Dibyendu Majumdar
@ 2017-03-12 19:27         ` Luc Van Oostenryck
  0 siblings, 0 replies; 6+ messages in thread
From: Luc Van Oostenryck @ 2017-03-12 19:27 UTC (permalink / raw)
  To: Dibyendu Majumdar; +Cc: Linux-Sparse

On Sun, Mar 12, 2017 at 06:00:33PM +0000, Dibyendu Majumdar wrote:
> I got confused by the numbering initially as I was expecting all
> pseudos within a single function to be numbered sequentially.

Yes.
I think they should, but in normal circonstances it doesn't matter.

> So I should just read following :
> 
> phisrc.64   %phi98(current) <- %r333
> 
> As:
> 
> %phi98(current) = %r333
> 
> And 98 just happens to be the identifier for the pseudo, and 'phi' is
> just to help the reader know that the value will go into a phi
> instruction later. Is that correct?

Absolutely.

-- Luc

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

end of thread, other threads:[~2017-03-12 19:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-12 14:11 Trying to understand linearized output Dibyendu Majumdar
2017-03-12 17:10 ` Luc Van Oostenryck
2017-03-12 17:15   ` Dibyendu Majumdar
2017-03-12 17:20     ` Luc Van Oostenryck
2017-03-12 18:00       ` Dibyendu Majumdar
2017-03-12 19:27         ` Luc Van Oostenryck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.