Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8303238: Create generalizations for existing LShift ideal transforms #12734

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Next Next commit
Comments from code review
  • Loading branch information
jaskarth committed Mar 7, 2023
commit bd1615614119b249377f69c79f77ac97d5d4c4f0
16 changes: 8 additions & 8 deletions src/hotspot/share/opto/mulnode.cpp
Expand Up @@ -847,9 +847,9 @@ Node *LShiftINode::Ideal(PhaseGVN *phase, bool can_reshape) {
}
}

// Check for "(x >> C1) << C2" which just masks off low bits
// Check for "(x >> C1) << C2"
if (add1_op == Op_RShiftI || add1_op == Op_URShiftI) {
// Special case C1 == C2
// Special case C1 == C2, which just masks off low bits
if (add1->in(2) == in(2)) {
// Convert to "(x & -(1 << C2))"
return new AndINode(add1->in(1), phase->intcon(-(1 << con)));
Expand Down Expand Up @@ -887,12 +887,12 @@ Node *LShiftINode::Ideal(PhaseGVN *phase, bool can_reshape) {
}
}

// Check for "((x >> C1) & Y) << C2" which just masks off more low bits
// Check for "((x >> C1) & Y) << C2"
if (add1_op == Op_AndI) {
Node *add2 = add1->in(1);
int add2_op = add2->Opcode();
if (add2_op == Op_RShiftI || add2_op == Op_URShiftI) {
// Special case C1 == C2
// Special case C1 == C2, which just masks off low bits
if (add2->in(2) == in(2)) {
// Convert to "(x & (Y << C2))"
Node* y_sh = phase->transform(new LShiftINode(add1->in(2), phase->intcon(con)));
Expand Down Expand Up @@ -1023,9 +1023,9 @@ Node *LShiftLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
}
}

// Check for "(x >> C1) << C2" which just masks off low bits
// Check for "(x >> C1) << C2"
if (add1_op == Op_RShiftL || add1_op == Op_URShiftL) {
// Special case C1 == C2
// Special case C1 == C2, which just masks off low bits
if (add1->in(2) == in(2)) {
// Convert to "(x & -(1 << C2))"
return new AndLNode(add1->in(1), phase->longcon(-(CONST64(1) << con)));
Expand Down Expand Up @@ -1063,12 +1063,12 @@ Node *LShiftLNode::Ideal(PhaseGVN *phase, bool can_reshape) {
}
}

// Check for "((x >> C1) & Y) << C2" which just masks off more low bits
// Check for "((x >> C1) & Y) << C2"
if (add1_op == Op_AndL) {
Node* add2 = add1->in(1);
int add2_op = add2->Opcode();
if (add2_op == Op_RShiftL || add2_op == Op_URShiftL) {
// Special case C1 == C2
// Special case C1 == C2, which just masks off low bits
if (add2->in(2) == in(2)) {
// Convert to "(x & (Y << C2))"
Node* y_sh = phase->transform(new LShiftLNode(add1->in(2), phase->intcon(con)));
Expand Down
Expand Up @@ -97,14 +97,14 @@ private static int rgbaToAbgr(int i) {
@State(Scope.Benchmark)
public static class BenchState {
int[] ints;
Random random = new Random();

public BenchState() {

}

@Setup
public void setup() {
Random random = new Random(1000);
ints = new int[64];
for (int i = 0; i < 64; i++) {
ints[i] = random.nextInt();
Expand Down