Skip to content

Commit

Permalink
[GR-53279] [GR-53391] [GR-53579] Various compiler crash fixes
Browse files Browse the repository at this point in the history
PullRequest: graal/17575
  • Loading branch information
gergo- committed Apr 24, 2024
2 parents 72f5ffc + 8bbfd82 commit 2f48e8f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009, 2024, 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
Expand Down Expand Up @@ -672,7 +672,7 @@ protected void emitForeignCallOp(ForeignCallLinkage linkage, Value targetAddress
@Override
public Variable emitReverseBytes(Value input) {
Variable result = newVariable(LIRKind.combine(input));
append(new AMD64ByteSwapOp(result, input));
append(new AMD64ByteSwapOp(result, asAllocatable(input)));
return result;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2024, 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
Expand Down Expand Up @@ -29,9 +29,9 @@
import jdk.graal.compiler.lir.LIRInstructionClass;
import jdk.graal.compiler.lir.Opcode;
import jdk.graal.compiler.lir.asm.CompilationResultBuilder;

import jdk.vm.ci.amd64.AMD64Kind;
import jdk.vm.ci.code.ValueUtil;
import jdk.vm.ci.meta.AllocatableValue;
import jdk.vm.ci.meta.Value;

@Opcode("BSWAP")
Expand All @@ -41,7 +41,7 @@ public final class AMD64ByteSwapOp extends AMD64LIRInstruction {
@Def({OperandFlag.REG, OperandFlag.HINT}) protected Value result;
@Use protected Value input;

public AMD64ByteSwapOp(Value result, Value input) {
public AMD64ByteSwapOp(Value result, AllocatableValue input) {
super(TYPE);
this.result = result;
this.input = input;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2024, 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
Expand Down Expand Up @@ -137,7 +137,7 @@ public ValueNode canonical(CanonicalizerTool tool, ValueNode forX, ValueNode for
// If the second argument is 1.0, then the result is the same as the first
// argument.
if (yValue == 1.0D) {
return x;
return forX;
}

// If the second argument is NaN, then the result is NaN.
Expand All @@ -147,19 +147,19 @@ public ValueNode canonical(CanonicalizerTool tool, ValueNode forX, ValueNode for

// x**-1 = 1/x
if (yValue == -1.0D) {
return new FloatDivNode(ConstantNode.forDouble(1), x);
return new FloatDivNode(ConstantNode.forDouble(1), forX);
}

// x**2 = x*x
if (yValue == 2.0D) {
return new MulNode(x, x);
return new MulNode(forX, forX);
}

// x**0.5 = sqrt(x)
// Note that Math.pow(Double.MAX_VALUE, 0.5) returns different value than
// Math.sqrt(Double.MAX_VALUE) until Java 17.
if (yValue == 0.5D && x.stamp(view) instanceof FloatStamp && ((FloatStamp) x.stamp(view)).lowerBound() >= 0.0D) {
return SqrtNode.create(x, view);
if (yValue == 0.5D && forX.stamp(view) instanceof FloatStamp xStamp && xStamp.lowerBound() >= 0.0D) {
return SqrtNode.create(forX, view);
}
}
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2024, 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
Expand Down Expand Up @@ -88,6 +88,9 @@ public static double compute(UnaryOperation op, double value) {
}

public static Stamp computeStamp(UnaryOperation op, Stamp valueStamp) {
if (valueStamp.isEmpty()) {
return StampFactory.forKind(JavaKind.Double).empty();
}
if (valueStamp instanceof FloatStamp) {
FloatStamp floatStamp = (FloatStamp) valueStamp;
switch (op) {
Expand Down

0 comments on commit 2f48e8f

Please sign in to comment.