From 61df7cc8b91365e487591ec8402e797a25790a79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20H=C3=A4ssig?= Date: Mon, 30 Mar 2026 06:27:30 +0000 Subject: [PATCH] 8380988: C2: Unexpected node in SuperWord truncation: UModI/UDivI Reviewed-by: epeter, jkarthikeyan --- src/hotspot/share/opto/superword.cpp | 2 + .../vectorization/TestSubwordTruncation.java | 46 ++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/opto/superword.cpp b/src/hotspot/share/opto/superword.cpp index d878b2b1d3d..53845a94c1c 100644 --- a/src/hotspot/share/opto/superword.cpp +++ b/src/hotspot/share/opto/superword.cpp @@ -2500,7 +2500,9 @@ static bool can_subword_truncate(Node* in, const Type* type) { switch (opc) { case Op_AbsI: case Op_DivI: + case Op_UDivI: case Op_ModI: + case Op_UModI: case Op_MinI: case Op_MaxI: case Op_CMoveI: diff --git a/test/hotspot/jtreg/compiler/vectorization/TestSubwordTruncation.java b/test/hotspot/jtreg/compiler/vectorization/TestSubwordTruncation.java index 2f6296e41d2..0a80a59efd4 100644 --- a/test/hotspot/jtreg/compiler/vectorization/TestSubwordTruncation.java +++ b/test/hotspot/jtreg/compiler/vectorization/TestSubwordTruncation.java @@ -29,7 +29,7 @@ import compiler.lib.generators.*; /* * @test - * @bug 8350177 8362171 8369881 8342095 + * @bug 8350177 8362171 8369881 8342095 8380988 * @summary Ensure that truncation of subword vectors produces correct results * @library /test/lib / * @run driver compiler.vectorization.TestSubwordTruncation @@ -448,6 +448,50 @@ public class TestSubwordTruncation { } } + @Test + @IR(counts = { IRNode.UMOD_I, ">0" }) + @Arguments(setup = "setupByteArray") + public Object[] testUMod(final byte[] in) { + int n = G.next().intValue(); + for (int i = 1; i < SIZE; i++) { + in[i] = (byte) Integer.remainderUnsigned(n, i); + } + + return new Object[] { Integer.valueOf(n), in }; + } + + @Check(test = "testUMod") + public void checkTestUMod(Object[] vals) { + int n = (Integer) vals[0]; + byte[] res = (byte[]) vals[1]; + for (int i = 1; i < SIZE; i++) { + byte val = (byte) Integer.remainderUnsigned(n, i); + Asserts.assertEQ(res[i], val); + } + } + + @Test + @IR(counts = { IRNode.UDIV_I, ">0" }) + @Arguments(setup = "setupByteArray") + public Object[] testUDiv(final byte[] in) { + int n = G.next().intValue(); + for (int i = 1; i < SIZE; i++) { + in[i] = (byte) Integer.divideUnsigned(n, i); + } + + return new Object[] { Integer.valueOf(n), in }; + } + + @Check(test = "testUDiv") + public void checkTestUDiv(Object[] vals) { + int n = (Integer) vals[0]; + byte[] res = (byte[]) vals[1]; + for (int i = 1; i < SIZE; i++) { + byte val = (byte) Integer.divideUnsigned(n, i); + Asserts.assertEQ(res[i], val); + } + } + @Test @IR(counts = { IRNode.CMP_LT_MASK, ">0" }) @Arguments(setup = "setupByteArray")