[llvm] LICM: hoist BO assoc when (C1 op LV) op C2 (PR #106999)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 4 01:04:00 PDT 2024
artagnon wrote:
> You can just assert that the op is commutative (after the associativity check). In general, all associative ops we support are also commutative.
Little confused by this. Aren't `FAdd` and `FMul` commutative, but not associative?
```cpp
bool isAssociative() const LLVM_READONLY;
static bool isAssociative(unsigned Opcode) {
return Opcode == And || Opcode == Or || Opcode == Xor ||
Opcode == Add || Opcode == Mul;
}
bool isCommutative() const LLVM_READONLY;
static bool isCommutative(unsigned Opcode) {
switch (Opcode) {
case Add: case FAdd:
case Mul: case FMul:
case And: case Or: case Xor:
return true;
default:
return false;
}
}
```
https://github.com/llvm/llvm-project/pull/106999
More information about the llvm-commits
mailing list