Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/hotspot/share/opto/superword.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2577,6 +2577,11 @@ static bool can_subword_truncate(Node* in, const Type* type) {
return false;
}

// Since casts specifically change the type of a node, stay on the safe side and do not truncate them.
if (in->is_ConstraintCast()) {
return false;
}

// Cannot be truncated:
switch (opc) {
case Op_AbsI:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,32 @@ public Object[] testRoundD(byte[] in) {
return new Object[] { in, res };
}

@Test(compLevel = CompLevel.C2)
@IR(counts = { IRNode.CAST_II, ">0" })
@Warmup(0)
public Object[] testCastII() {
byte[] bytes = new byte[400];
intField = 6;
int i = 0;
int j = 1;

do {
bytes[j] = (byte) i;
int k = 1;

do {
i <<= intField;
i += (k ^ i);
i -= j;

for (int u = 1; 1 > u; u++) {
}
} while (++k < 8);
} while (++j < 191);

return new Object[] { bytes };
}

public static void main(String[] args) {
TestFramework.run();
}
Expand Down