Update doc loop op#2337
Conversation
| %my_local = Add(%a, %b) | ||
| %b_out = Sub(%a, %b) | ||
| %my_local = Add(%a, %b_in) | ||
| %b_out = Sub(%a, %b_in) |
There was a problem hiding this comment.
| %b_out = Sub(%a, %b_in) | |
| // The value of b_out is used as the value of b_in in the next iteration. Note that it doesn't affect the value of the b_in passed into this operator. | |
| %b_out = Sub(%a, %b_in) |
We don't have assignment operator. To match the C code below, we need some comments to explain it.
There was a problem hiding this comment.
I added a few more comments to address the two points you mention.
| /* Implicitly-defined code: bind actual parameter values | ||
| to formal parameter variables of loop-body */ | ||
| keepgoing_in = keepgoing_out; | ||
| b_in = b_out; |
There was a problem hiding this comment.
| b_in = b_out; | |
| // The variable b_in is passed into the block by value, so the original value of b_in won't be changed. | |
| b_in = b_out; |
| %user_defined_vals = Add(%b, %b) | ||
| return %keepgoing_out, %b_out, %user_defined_vals | ||
| %my_local = Add(%a, %b_in) | ||
| %b_out = Sub(%a, %b_in) // outgoing value of loop-carried-dependency b |
There was a problem hiding this comment.
There is no b anymore. This statement doesn't explicitly say that the last value of b_out in one iteration will be the value of b_in in the next iteration.
There was a problem hiding this comment.
That's what the pseudo-code is for, to show how b_out is copied into b_in that assignment statement. Explanatory comments may be more useful outside, in the description. I will see if I can add any more to clarify things there.
| %b_out = Sub(%a, %b_in) // outgoing value of loop-carried-dependency b | ||
| %keepgoing_out = Greater(%my_local, %b_out) // outgoing loop-termination-condition | ||
| %user_defined_val = Add(%b_in, %b_in) // scan-output value to be accumulated | ||
| return %keepgoing_out, %b_out, %user_defined_val |
There was a problem hiding this comment.
[nit] Given the return … here, it looks like the Loop will terminate at the end of the first iteration.
There was a problem hiding this comment.
I think it is more than 1 iteration (in the whole example, you mean?), though it may terminate in 2 or 3 iterations (haven't checked fully). I just reused the existing loop logic, thought it is an artificial one.
| // my_local = 123; // Can't do this. my_local was defined in the the body | ||
| // int t = my_local; // Can't do this. my_local is not accessible here. | ||
|
|
||
| // These below values are live-out from the loop and therefore accessible |
There was a problem hiding this comment.
[nit]
| // These below values are live-out from the loop and therefore accessible | |
| // These below values are bound to the outputs of the loop and therefore accessible |
wschin
left a comment
There was a problem hiding this comment.
Looks much clearer! Thanks.
* Clarify example in Loop documentation * Regenerate op documentation * generate op documentation * Address PR review comment * Address PR feedback * Update defs.cc * Update Changelog.md * Update Operators.md
Change example in Loop's documentation to clarify things. (Redo of earlier PR #2144 to incorporate various suggestions.)