RFR: 8375443: AVX-512: Disabling through UseSHA doesn't affect UseSHA3Intrinsics

Manuel Hässig mhaessig at openjdk.org
Fri Jan 16 09:48:21 UTC 2026


On Fri, 16 Jan 2026 08:41:20 GMT, Ramkumar Sunderbabu <rsunderbabu at openjdk.org> wrote:

> UseSHA flag is not respected while enabling/disabling UseSHA3Intrinsics flag in x86 builds.
> Added UseSHA in the mix.
> 
> Testing: Only Basic testing done. I will run more compiler related testing.

Thank you for fixing this bug, @rsunderbabu! Your code changes look good. I only have cosmetic suggestions. However, since this is a bug, please add a regression test. [`compiler/arguments/TestUseCountTrailingZerosInstructionOnSupportedCPU.java`](https://github.com/openjdk/jdk/blob/master/test/hotspot/jtreg/compiler/arguments/TestUseCountTrailingZerosInstructionOnSupportedCPU.java) should be a good inspiration.

src/hotspot/cpu/x86/vm_version_x86.cpp line 2:

> 1: /*
> 2:  * Copyright (c) 1997, 2027, Oracle and/or its affiliates. All rights reserved.

Suggestion:

 * Copyright (c) 1997, 2026, Oracle and/or its affiliates. All rights reserved.

Not so fast ;)

src/hotspot/cpu/x86/vm_version_x86.cpp line 1349:

> 1347:       }
> 1348:   } else if (UseSHA3Intrinsics) {
> 1349:       warning("Intrinsics for SHA3-224, SHA3-256, SHA3-384 and SHA3-512 crypto hash functions not available on this CPU.");

This warning might be a bit misleading when `-XX:-UseSHA -XX:+UseSHA3Intrinsics` is passed on a machine that supports the instructions.

src/hotspot/cpu/x86/vm_version_x86.cpp line 1351:

> 1349:       warning("Intrinsics for SHA3-224, SHA3-256, SHA3-384 and SHA3-512 crypto hash functions not available on this CPU.");
> 1350:       FLAG_SET_DEFAULT(UseSHA3Intrinsics, false);
> 1351:   }

Suggestion:

  if (UseSHA && supports_evex() && supports_avx512bw()) {
    if (FLAG_IS_DEFAULT(UseSHA3Intrinsics)) {
      FLAG_SET_DEFAULT(UseSHA3Intrinsics, true);
      UseSHA3Intrinsics = true;
    }
  } else if (UseSHA3Intrinsics) {
    warning("Intrinsics for SHA3-224, SHA3-256, SHA3-384 and SHA3-512 crypto hash functions not available on this CPU.");
    FLAG_SET_DEFAULT(UseSHA3Intrinsics, false);
  }

Please fix the indentation to two spaces.

-------------

Changes requested by mhaessig (Committer).

PR Review: https://git.openjdk.org/jdk/pull/29266#pullrequestreview-3669825317
PR Review Comment: https://git.openjdk.org/jdk/pull/29266#discussion_r2697706053
PR Review Comment: https://git.openjdk.org/jdk/pull/29266#discussion_r2697735783
PR Review Comment: https://git.openjdk.org/jdk/pull/29266#discussion_r2697719691


More information about the hotspot-dev mailing list