diff --git a/src/hotspot/share/opto/superword.cpp b/src/hotspot/share/opto/superword.cpp index 510cb1b51de..2316b0bb49a 100644 --- a/src/hotspot/share/opto/superword.cpp +++ b/src/hotspot/share/opto/superword.cpp @@ -2597,6 +2597,9 @@ static bool can_subword_truncate(Node* in, const Type* type) { case Op_IsFiniteD: case Op_IsInfiniteF: case Op_IsInfiniteD: + case Op_CmpLTMask: + case Op_RoundF: + case Op_RoundD: case Op_ExtractS: case Op_ExtractC: case Op_ExtractB: diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java b/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java index 1b843e27587..d699ba1acd8 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java @@ -585,6 +585,21 @@ public class IRNode { beforeMatchingNameRegex(CMP_P, "CmpP"); } + public static final String CMP_LT_MASK = PREFIX + "CMP_LT_MASK" + POSTFIX; + static { + beforeMatchingNameRegex(CMP_LT_MASK, "CmpLTMask"); + } + + public static final String ROUND_F = PREFIX + "ROUND_F" + POSTFIX; + static { + beforeMatchingNameRegex(ROUND_F, "RoundF"); + } + + public static final String ROUND_D = PREFIX + "ROUND_D" + POSTFIX; + static { + beforeMatchingNameRegex(ROUND_D, "RoundD"); + } + public static final String COMPRESS_BITS = PREFIX + "COMPRESS_BITS" + POSTFIX; static { beforeMatchingNameRegex(COMPRESS_BITS, "CompressBits"); diff --git a/test/hotspot/jtreg/compiler/vectorization/TestSubwordTruncation.java b/test/hotspot/jtreg/compiler/vectorization/TestSubwordTruncation.java index 5985367b265..43861c789ba 100644 --- a/test/hotspot/jtreg/compiler/vectorization/TestSubwordTruncation.java +++ b/test/hotspot/jtreg/compiler/vectorization/TestSubwordTruncation.java @@ -389,6 +389,45 @@ public class TestSubwordTruncation { } } + @Test + @IR(counts = { IRNode.CMP_LT_MASK, ">0" }) + @Arguments(setup = "setupByteArray") + public Object[] testCmpLTMask(byte[] in) { + char[] res = new char[SIZE]; + + for (int i = 0; i < SIZE; i++) { + res[i] = (char) (in[i] >= 0 ? in[i] : 256 + in[i]); + } + + return new Object[] { in, res }; + } + + @Test + @IR(counts = { IRNode.ROUND_F, ">0" }) + @Arguments(setup = "setupByteArray") + public Object[] testRoundF(byte[] in) { + short[] res = new short[SIZE]; + + for (int i = 0; i < SIZE; i++) { + res[i] = (short) Math.round(in[i] * 10.F); + } + + return new Object[] { in, res }; + } + + @Test + @IR(counts = { IRNode.ROUND_D, ">0" }) + @Arguments(setup = "setupByteArray") + public Object[] testRoundD(byte[] in) { + short[] res = new short[SIZE]; + + for (int i = 0; i < SIZE; i++) { + res[i] = (short) Math.round(in[i] * 10.0); + } + + return new Object[] { in, res }; + } + public static void main(String[] args) { TestFramework.run(); }