JDK-8347645 : C2: XOR bounded value handling blocks constant folding
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 17,21,24
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2025-01-14
  • Updated: 2025-04-14
  • Resolved: 2025-04-04
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 25
25 b18Fixed
Related Reports
Relates :  
Relates :  
Description
JDK-8267332 adds an optimization that adds boundaries for XOR results in XorI/LNode::Value, but that optimization take precedence over the constant folding path in AddNode::Value.

I (liach) think the problem traces back to JDK-8261008 which adds Xor optimization as XorI/LNode::Value instead of XorI/LNode::add_ring. The override to ::Value should be removed and all optimizations should happen in add_ring.
Comments
Changeset: 37f8e419 Branch: master Author: Johannes Graham <j3graham@gmail.com> Date: 2025-04-04 13:24:22 +0000 URL: https://git.openjdk.org/jdk/commit/37f8e419f9661ba30b3c34bd9fecef71ab1eddb1
04-04-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/23089 Date: 2025-01-13 22:16:20 +0000
15-01-2025

ILW = Missed optimization opportunity (constant folding), with XORs, no workaround = MLH = P4
14-01-2025

See https://github.com/openjdk/jdk/pull/23089 for a contributor PR. However, it uses a simple approach to patch an ad-hoc constant-folding to before the boundary optimization, instead of restructuring code to add_ring as for other nodes.
14-01-2025