Skip to content

Commit cea50b3

Browse files
committed
[GR-70990] Extract correct bit when lowering SimdToBitMask on vectors of shorts
PullRequest: graal/22454
2 parents 1728631 + e1ed20a commit cea50b3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/vector/phases/amd64/AMD64VectorLoweringPhase.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,11 @@ private static void lowerSimdToBitMask(SimdToBitMaskNode node, VectorAMD64 vecto
381381
SimdStamp byteStamp = SimdStamp.broadcast(IntegerStamp.create(Byte.SIZE), inputStamp.getVectorLength() * 2);
382382
ValueNode input = graph.addOrUnique(ReinterpretNode.create(byteStamp, node.getValue(), NodeView.DEFAULT));
383383
SimdToBitMaskNode bitmask = graph.unique(new SimdToBitMaskNode(input));
384-
ConstantNode compressMask = ConstantNode.forLong(0x5555555555555555L, graph);
384+
/*
385+
* Extract the higher bit out of each two-bit pair. The compress mask for this is
386+
* 0b...10_10_10_10, i.e., 0x...AA.
387+
*/
388+
ConstantNode compressMask = ConstantNode.forLong(0xAAAAAAAAAAAAAAAAL, graph);
385389
ValueNode result = graph.addOrUniqueWithInputs(IntegerConvertNode.convert(new CompressBitsNode(bitmask, compressMask), node.stamp(NodeView.DEFAULT), NodeView.DEFAULT));
386390
node.replaceAtUsagesAndDelete(result);
387391
}

0 commit comments

Comments
 (0)