RFR: 8282204: Use lea instructions for arithmetic operations on x86_64 [v5]

Jie Fu jiefu at openjdk.java.net
Fri Feb 25 23:22:54 UTC 2022


On Fri, 25 Feb 2022 15:48:21 GMT, Quan Anh Mai <duke at openjdk.java.net> wrote:

> May I ask what version of llvm are you using? Because due to [this patch](https://reviews.llvm.org/D32277), clang from 6.0.0 refuses to generate a 3-op `lea` for this operation while gcc seems to not care (although I checked msvc and also rustc all refrain from generating a complex `lea`).

The llvm info

Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin19.6.0


I tested the following code pattern with `clang -c  -O{1, 2, 3} ...`.
`lea` is generated for all the cases.

int testInt1(int x, int y) {
  return x + (y << 2) + 32;
}

int testInt2(int x, int y) {
  return x + (y << 2);
}

int testInt3(int x, int y) {
  return x + y + 16;
}

long testLong1(long x, long y) {
  return x + (y << 2) + 32;
}

long testLong2(long x, long y) {
  return x + (y << 2);
}

long testLong3(long x, long y) {
  return x + y + 16;
}

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

PR: https://git.openjdk.java.net/jdk/pull/7560


More information about the hotspot-compiler-dev mailing list