diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/CachedReplaceVectorNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/CachedReplaceVectorNode.java index 323b2d034ecb3aea09df9e62de426ddec4c60f2b..9bd54bbee5eb3b699fd9d50cef380a224863ddba 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/CachedReplaceVectorNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/CachedReplaceVectorNode.java @@ -59,6 +59,9 @@ final class CachedReplaceVectorNode extends CachedVectorNode { private final BranchProfile resizeProfile = BranchProfile.create(); private final BranchProfile sharedProfile = BranchProfile.create(); + private final ConditionProfile valueLengthOneProfile = ConditionProfile.createBinaryProfile(); + private final ConditionProfile emptyReplacementProfile = ConditionProfile.createBinaryProfile(); + private final RType valueType; private final RType castType; private final boolean updatePositionNames; @@ -190,12 +193,12 @@ final class CachedReplaceVectorNode extends CachedVectorNode { } int replacementLength = positionsCheckNode.getSelectedPositionsCount(positionProfiles); - if (replacementLength == 0) { + if (emptyReplacementProfile.profile(replacementLength == 0)) { /* Nothing to modify */ return vector; } - if (valueLength != 1) { + if (valueLengthOneProfile.profile(valueLength != 1)) { verifyValueLength(positionProfiles, valueLength); } @@ -227,7 +230,7 @@ final class CachedReplaceVectorNode extends CachedVectorNode { * Interestingly we always need to provide not NOT_MULTIPLE_REPLACEMENT error messages * for multi-dimensional deletes. */ - if ((this.numberOfDimensions > 1 && isNullValue()) || replacementLength % valueLength != 0) { + if ((this.numberOfDimensions > 1 && isNullValue()) || (replacementLength != valueLength && replacementLength % valueLength != 0)) { if (this.numberOfDimensions > 1) { errorBranch.enter(); throw RError.error(this, RError.Message.NOT_MULTIPLE_REPLACEMENT); diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionCheckSubsetNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionCheckSubsetNode.java index a7943caf7d1132a64aebb47f8cc7dfe98361af69..9efd068bd02acbe67f7cfc9c5b1b7f181d75c4d1 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionCheckSubsetNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/access/vector/PositionCheckSubsetNode.java @@ -73,7 +73,7 @@ abstract class PositionCheckSubsetNode extends PositionCheckNode { } protected static boolean isMultiplesOf(int a, int b) { - return b != 0 && a % b == 0; + return b != 0 && (a == b || a % b == 0); } @Specialization(contains = "doLogicalMultiplesInBounds")