Skip to content

Commit 775f48d

Browse files
committed
8365570: C2 fails assert(false) failed: Unexpected node in SuperWord truncation: CastII
Reviewed-by: chagedorn, thartmann, epeter
1 parent 9932c78 commit 775f48d

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

src/hotspot/share/opto/superword.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2007, 2025, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2007, 2026, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -2482,6 +2482,11 @@ static bool can_subword_truncate(Node* in, const Type* type) {
24822482
return false;
24832483
}
24842484

2485+
// Since casts specifically change the type of a node, stay on the safe side and do not truncate them.
2486+
if (in->is_ConstraintCast()) {
2487+
return false;
2488+
}
2489+
24852490
// Cannot be truncated:
24862491
switch (opc) {
24872492
case Op_AbsI:

test/hotspot/jtreg/compiler/vectorization/TestSubwordTruncation.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2025, 2026, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -479,6 +479,32 @@ public Object[] testRoundD(byte[] in) {
479479
return new Object[] { in, res };
480480
}
481481

482+
@Test
483+
@IR(counts = { IRNode.CAST_II, ">0" })
484+
@Warmup(0)
485+
public Object[] testCastII() {
486+
byte[] bytes = new byte[400];
487+
intField = 6;
488+
int i = 0;
489+
int j = 1;
490+
491+
do {
492+
bytes[j] = (byte) i;
493+
int k = 1;
494+
495+
do {
496+
i <<= intField;
497+
i += (k ^ i);
498+
i -= j;
499+
500+
for (int u = 1; 1 > u; u++) {
501+
}
502+
} while (++k < 8);
503+
} while (++j < 191);
504+
505+
return new Object[] { bytes };
506+
}
507+
482508
public static void main(String[] args) {
483509
TestFramework.run();
484510
}

0 commit comments

Comments
 (0)