[llvm] Min and Max are associative (PR #171268)

via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 8 23:04:20 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-ir

Author: None (natanelh-mobileye)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/171268.diff


1 Files Affected:

- (modified) llvm/include/llvm/IR/Instruction.h (+3-2) 


``````````diff
diff --git a/llvm/include/llvm/IR/Instruction.h b/llvm/include/llvm/IR/Instruction.h
index 900384432d75d..c4ef54fbd497d 100644
--- a/llvm/include/llvm/IR/Instruction.h
+++ b/llvm/include/llvm/IR/Instruction.h
@@ -737,12 +737,13 @@ class Instruction : public User,
   ///
   ///   Associative operators satisfy:  x op (y op z) === (x op y) op z
   ///
-  /// In LLVM, the Add, Mul, And, Or, and Xor operators are associative.
+  /// In LLVM, the Add, Mul, And, Or, Xor, Min and Max operators are associative.
   ///
   bool isAssociative() const LLVM_READONLY;
   static bool isAssociative(unsigned Opcode) {
     return Opcode == And || Opcode == Or || Opcode == Xor ||
-           Opcode == Add || Opcode == Mul;
+           Opcode == Add || Opcode == Mul || Opcode == Min ||
+           Opcode == Max;
   }
 
   /// Return true if the instruction is commutative:

``````````

</details>


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


More information about the llvm-commits mailing list