[feat] Modify incremental canonicalizer to user custom tornado floating
read replacement phase to avoid making reads floating
@@ -28,13 +28,13 @@ package uk.ac.manchester.tornado.drivers.opencl.graal.compiler;
import static org.graalvm.compiler.core.common.GraalOptions.ConditionalElimination;
import static org.graalvm.compiler.core.common.GraalOptions.ImmutableCode;
import static org.graalvm.compiler.core.common.GraalOptions.OptFloatingReads;
+import static org.graalvm.compiler.core.common.GraalOptions.OptReadElimination;
import static org.graalvm.compiler.core.common.GraalOptions.ReassociateInvariants;
import org.graalvm.compiler.loop.phases.ReassociateInvariantPhase;
import org.graalvm.compiler.nodes.spi.LoweringTool;
import org.graalvm.compiler.options.OptionValues;
import org.graalvm.compiler.phases.common.CanonicalizerPhase;
-import org.graalvm.compiler.phases.common.FloatingReadPhase;
import org.graalvm.compiler.phases.common.FrameStateAssignmentPhase;
import org.graalvm.compiler.phases.common.GuardLoweringPhase;
import org.graalvm.compiler.phases.common.IncrementalCanonicalizerPhase;
@@ -42,6 +42,7 @@ import org.graalvm.compiler.phases.common.IterativeConditionalEliminationPhase;
import org.graalvm.compiler.phases.common.LoweringPhase;
import org.graalvm.compiler.phases.common.RemoveValueProxyPhase;
+import uk.ac.manchester.tornado.drivers.opencl.graal.phases.TornadoFloatingReadReplacement;
import uk.ac.manchester.tornado.runtime.graal.compiler.TornadoMidTier;
import uk.ac.manchester.tornado.runtime.graal.phases.ExceptionCheckingElimination;
import uk.ac.manchester.tornado.runtime.graal.phases.TornadoMemoryPhiElimination;
@@ -59,27 +60,23 @@ public class OCLMidTier extends TornadoMidTier {
canonicalizer = CanonicalizerPhase.create();
}
- // if (OptCanonicalizer.getValue()) {
appendPhase(canonicalizer);
- // }
// if(!OpenCLTornadoBackend.ENABLE_EXCEPTIONS)
appendPhase(new ExceptionCheckingElimination());
- // appendPhase(new LockEliminationPhase());
if (OptFloatingReads.getValue(options)) {
- appendPhase(new IncrementalCanonicalizerPhase<>(canonicalizer, new FloatingReadPhase()));
+ appendPhase(new IncrementalCanonicalizerPhase<>(canonicalizer, new TornadoFloatingReadReplacement()));
}
- // if (OptReadElimination.getValue(options)) {
+ if (OptReadElimination.getValue(options)) {
// appendPhase(new EarlyReadEliminationPhase(canonicalizer));
- // }
+ }
+
appendPhase(new TornadoMemoryPhiElimination());
appendPhase(new RemoveValueProxyPhase());
- // if (OptCanonicalizer.getValue()) {
appendPhase(canonicalizer);
- // }
if (ConditionalElimination.getValue(options)) {
appendPhase(new IterativeConditionalEliminationPhase(canonicalizer, true));
@@ -87,9 +84,7 @@ public class OCLMidTier extends TornadoMidTier {
appendPhase(new GuardLoweringPhase());
- // if (OptCanonicalizer.getValue()) {
appendPhase(canonicalizer);
- // }
// TODO disable as it introduces loop limit checks
// appendPhase(new IncrementalCanonicalizerPhase<>(canonicalizer, new
