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

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 14 20:49:36 PST 2023


================
@@ -321,6 +321,27 @@ void Instruction::setNonNeg(bool b) {
                          (b * PossiblyNonNegInst::NonNeg);
 }
 
+bool Instruction::hasAllowReassocOfAllOperand() const {
+  return all_of(operands(), [](Value *V) {
+    if (!isa<FPMathOperator>(V))
+      return true;
+
+    auto *FPOp = cast<FPMathOperator>(V);
+    switch (FPOp->getOpcode()) {
+    case Instruction::FNeg:
+    case Instruction::FAdd:
+    case Instruction::FSub:
+    case Instruction::FMul:
+    case Instruction::FDiv:
+    case Instruction::FRem:
+      return FPOp->hasAllowReassoc();
+
+    default:
+      return true;
----------------
arsenm wrote:

default should be false?

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


More information about the llvm-commits mailing list