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

via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 7 05:01:30 PST 2023


================
@@ -177,6 +177,15 @@ void Instruction::setNonNeg(bool b) {
                          (b * PossiblyNonNegInst::NonNeg);
 }
 
+bool Instruction::hasAllowReassocOfAllOperand() const {
----------------
vfdff wrote:

* I find a case in llvm\test\Transforms\InstCombine\fmul.ll, which says the reassoc flag can propagates, does it right ?
  It seems against our intentions to revise.
```
; (X*Y) * X => (X*X) * Y
; The transform only requires 'reassoc', but test other FMF in
; the commuted variants to make sure FMF propagates as expected.

define float @reassoc_common_operand1(float %x, float %y) {
; CHECK-LABEL: @reassoc_common_operand1(
; CHECK-NEXT:    [[TMP1:%.*]] = fmul reassoc float [[X:%.*]], [[X]]
; CHECK-NEXT:    [[MUL2:%.*]] = fmul reassoc float [[TMP1]], [[Y:%.*]]
; CHECK-NEXT:    ret float [[MUL2]]
;
  %mul1 = fmul float %x, %y
  %mul2 = fmul reassoc float %mul1, %x
  ret float %mul2
}
```

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


More information about the llvm-commits mailing list