Patch for misleading comment in src/share/vm/opto/node.cpp
Peter B. Kessler
Peter.Kessler at Sun.COM
Mon Feb 23 11:15:17 PST 2009
Peter B. Kessler wrote:
> This comment is so wrong as almost to qualify as malicious. Here's a
> patch that might help.
>
> src/share/vm/opto/node.cpp
>
> 971 // If you modify the 'this' pointer's inputs, you must use 'set_req' with
> 972 // def-use info. If you are making a new Node (either as the new root or
> 973 // some new internal piece) you must NOT use set_req with def-use info.
> 974 // You can make a new Node with either 'new' or 'clone'. In either case,
> 975 // def-use info is (correctly) not generated.
> 976 // Example: reshape "(X+3)+4" into "X+7":
> 977 // set_req(1,in(1)->in(1) /* grab X */, du /* must use DU on 'this' */);
> 978 // set_req(2,phase->intcon(7),du);
> 979 // return this;
> - 980 // Example: reshape "X*4" into "X<<1"
> - 981 // return new (C,3) LShiftINode( in(1), phase->intcon(1) );
> + 980 // Example: reshape "X*4" into "X<<2"
> + 981 // return new (C,3) LShiftINode( in(1), phase->intcon(2) );
> 982 //
> 983 // You must call 'phase->transform(X)' on any new Nodes X you make, except
> - 984 // for the returned root node. Example: reshape "X*31" with "(X<<5)-1".
> - 985 // Node *shift=phase->transform(new(C,3)LShiftINode(in(1),phase->intcon(5)));
> - 986 // return new (C,3) AddINode(shift, phase->intcon(-1));
> + 984 // for the returned root node. Example: reshape "X*31" with "(X<<5)-X".
> + 985 // Node *shift=phase->transform(new(C,3)LShiftINode(in(1),phase->intcon(5)));
> + 986 // return new (C,3) SubINode(shift, phase->intcon(in(1)));
This last line should probably be
+ 986 // return new (C,3) SubINode(shift, in(1));
but I admit I'm a noob in this part of the code. (Which is why I was reading the comments. :-)
... peter
> The code *does* implement the transforms shown, but the transforms
> themselves are so wrong that it doesn't give me warm fuzzy feelings
> about trusting the author of this comment to transform my code. (And I
> have some worries about overflows and sign bits on the last transform,
> but I haven't checked them out.)
>
> ... peter
More information about the hotspot-compiler-dev
mailing list