Skip to content

Commit

Permalink
Fix String.compareTo AVX512 intrinsic typos.
Browse files Browse the repository at this point in the history
  • Loading branch information
mukel committed Aug 12, 2019
1 parent 8d95519 commit ce7a196
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
AMD64Address.Scale scale2 = null;

// if (ae != StrIntrinsicNode::LL) {
if (kind1 == JavaKind.Byte && kind2 == JavaKind.Byte) {
if (!(kind1 == JavaKind.Byte && kind2 == JavaKind.Byte)) {
stride2x2 = 0x20;
}

Expand Down Expand Up @@ -531,7 +531,7 @@ public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
masm.notq(cnt1);
masm.bsfq(cnt2, cnt1);
// if (ae != StrIntrinsicNode::LL) {
if (kind1 != JavaKind.Byte && kind2 != JavaKind.Byte) {
if (!(kind1 == JavaKind.Byte && kind2 == JavaKind.Byte)) {
// Divide diff by 2 to get number of chars
masm.sarl(cnt2, 1);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package org.graalvm.compiler.replacements.test;

import org.graalvm.compiler.core.test.GraalCompilerTest;
import org.junit.Test;

// JDK-8228903
public final class StringCompareToAVX512Test extends GraalCompilerTest {

public static int compareTo(String str1, String str2) {
return str1.compareTo(str2);
}

@Test
public void testLatin1VsUtf16_2() {
String latin1 = "000000001111111122222222333333334444444455555555666666667777777\u0099888888889";
String utf16 = "000000001111111122222222333333334444444455555555666666667777777\u0699888888889";
test("compareTo", latin1, utf16);
test("compareTo", utf16, latin1);
}

@Test
public void testLatin1VsUtf16_3() {
String latin1 = "00000000111111112222222233333333444444445555555566666666777777778888888\u008799999999AAAAAAAAB";
String utf16 = "00000000111111112222222233333333444444445555555566666666777777778888888\u058799999999AAAAAAAAB";
test("compareTo", latin1, utf16);
test("compareTo", utf16, latin1);
}

@Test
public void testLatin1VsUtf16() {
// java.lang.AssertionError: expected:<-1536> but was:<0>
String latin1 = "00000000111111112222222233333333\u0099444444455555555";
String utf16 = "00000000111111112222222233333333\u0699xxxxxxxxxxxxxxx";
test("compareTo", latin1, utf16);
test("compareTo", utf16, latin1);
}
}

0 comments on commit ce7a196

Please sign in to comment.