[llvm] Min and Max are associative (PR #171268)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 8 23:03:49 PST 2025
https://github.com/natanelh-mobileye created https://github.com/llvm/llvm-project/pull/171268
None
>From 18bf36bcb6dd8e55b4587fa162aa65e03e2cd385 Mon Sep 17 00:00:00 2001
From: natanelh-mobileye <155897558+natanelh-mobileye at users.noreply.github.com>
Date: Thu, 22 Feb 2024 15:58:00 +0200
Subject: [PATCH] Min and Max are associative
---
llvm/include/llvm/IR/Instruction.h | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
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:
More information about the llvm-commits
mailing list