[llvm] [InstCombine] Fix the correctness of missing check reassoc attribute (PR #71277)

via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 27 02:34:02 PDT 2024


vfdff wrote:

I think it is difficult to accurately describe which operands need to have the reassoc attribute. A case for point
```
define float @reassoc_common_operand1(float %x, float %y) {
  %mul0 = fmul float %y, 2.0
  %mul1 = fmul reassoc float %x, 1.0
  %mul2 = fmul reassoc float %mul1, %mul0
  ret float %mul2
}
```

We may think the above case can't be fold because the **%mul0** missing reassoc attribute, but in fact we can fold the %mul1 into %mul2. Therefore, it is not appropriate to ensure that all operands have reassoc attribute as a prerequisite for optimization.


https://github.com/llvm/llvm-project/pull/71277


More information about the llvm-commits mailing list