File tree 2 files changed +21
-2
lines changed
compiler/src/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes
2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -183,4 +183,16 @@ public NodeSourcePosition getNoDeoptSuccessorPosition() {
183
183
public void setNoDeoptSuccessorPosition (NodeSourcePosition noDeoptSuccessorPosition ) {
184
184
this .noDeoptSuccessorPosition = noDeoptSuccessorPosition ;
185
185
}
186
+
187
+ /**
188
+ * Determine if the this guard will lead to an unconditional {@link DeoptimizeNode} because its
189
+ * condition is a constant.
190
+ */
191
+ public boolean willDeoptUnconditionally () {
192
+ if (getCondition () instanceof LogicConstantNode ) {
193
+ LogicConstantNode c = (LogicConstantNode ) getCondition ();
194
+ return c .getValue () == negated ;
195
+ }
196
+ return false ;
197
+ }
186
198
}
Original file line number Diff line number Diff line change 36
36
import org .graalvm .compiler .nodeinfo .InputType ;
37
37
import org .graalvm .compiler .nodeinfo .NodeInfo ;
38
38
import org .graalvm .compiler .nodes .GraphState .StageFlag ;
39
+ import org .graalvm .compiler .nodes .GuardNode ;
39
40
import org .graalvm .compiler .nodes .NodeView ;
40
41
import org .graalvm .compiler .nodes .ValueNode ;
41
42
import org .graalvm .compiler .nodes .extended .GuardedNode ;
@@ -121,8 +122,14 @@ private boolean overflowVisibleSideEffect() {
121
122
122
123
@ Override
123
124
public boolean verify () {
124
- GraalError .guarantee ((!canDivideByZero () && !overflowVisibleSideEffect ()) || graph ().isAfterStage (StageFlag .FIXED_READS ),
125
- "Floating irem must never create an exception or trap" );
125
+ /*
126
+ * Special case unconditionally deopting rem operations: Other optimziations can lead to
127
+ * graphs where the rem operation will unconditionally deopt.
128
+ */
129
+ boolean guardWillAlwaysDeopt = getGuard () != null && getGuard () instanceof GuardNode && ((GuardNode ) getGuard ()).willDeoptUnconditionally ();
130
+ boolean cannotDeopt = (!canDivideByZero () && !overflowVisibleSideEffect ());
131
+ boolean isAfterStage = graph ().isAfterStage (StageFlag .FIXED_READS );
132
+ GraalError .guarantee (guardWillAlwaysDeopt || cannotDeopt || isAfterStage , "Floating irem must never create an exception or trap" );
126
133
return super .verify ();
127
134
}
128
135
}
You can’t perform that action at this time.
0 commit comments