RFR: 8280123: C2: Infinite loop in CMoveINode::Ideal during IGVN
Tobias Hartmann
thartmann at openjdk.java.net
Thu Jan 20 07:49:49 UTC 2022
On Tue, 18 Jan 2022 18:57:02 GMT, Vladimir Ivanov <vlivanov at openjdk.org> wrote:
> There's a discrepancy between `CMoveNode::Ideal()` and `CMoveINode::Ideal()` in the way how constants are detected:
> the former looks for `Con` nodes (`in(IfFalse)->is_Con()`) while the latter checks node types (e.g., `phase->type(in(IfFalse)) == TypeInt::ZERO`). It leads to infinite loop during IGVN (where `CMoveNode::Ideal()` and `CMoveINode::Ideal()` repeatedly rotate `CMoveI` node) because `CMoveNode::Ideal()` don't consider `CastII` to a constant as a constant while `CMoveINode::Ideal()` does.
>
> The fix migrates `CMoveNode::Ideal()` away from `Node::is_Con()` to node types.
>
> Testing: hs-tier1 - hs-tier4
Looks good. I added some minor cleanup suggestions.
src/hotspot/share/opto/movenode.cpp line 87:
> 85: assert(in(Condition) != this &&
> 86: in(IfFalse) != this &&
> 87: in(IfTrue) != this, "dead loop in CMoveNode::Ideal" );
Suggestion:
in(IfTrue) != this, "dead loop in CMoveNode::Ideal");
src/hotspot/share/opto/movenode.cpp line 97:
> 95: if (in(Condition)->is_Bool()) {
> 96: BoolNode* b = in(Condition)->as_Bool();
> 97: BoolNode* b2 = b->negate(phase);
Suggestion:
BoolNode* b = in(Condition)->as_Bool()->negate(phase);
src/hotspot/share/opto/movenode.cpp line 98:
> 96: BoolNode* b = in(Condition)->as_Bool();
> 97: BoolNode* b2 = b->negate(phase);
> 98: return make(in(Control), phase->transform(b2), in(IfTrue), in(IfFalse), _type);
Suggestion:
return make(in(Control), phase->transform(b), in(IfTrue), in(IfFalse), _type);
test/hotspot/jtreg/compiler/c2/TestCMoveInfiniteGVN.java line 25:
> 23:
> 24: /*
> 25: * @test
Suggestion:
* @test
* @key stress randomness
-------------
Marked as reviewed by thartmann (Reviewer).
PR: https://git.openjdk.java.net/jdk/pull/7133
More information about the hotspot-compiler-dev
mailing list