aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Instruction.h7
-rw-r--r--lib/VMCore/ConstantFold.cpp3
-rw-r--r--lib/VMCore/Instruction.cpp2
3 files changed, 5 insertions, 7 deletions
diff --git a/include/llvm/Instruction.h b/include/llvm/Instruction.h
index 88f5ce1b26..89bb9fdf42 100644
--- a/include/llvm/Instruction.h
+++ b/include/llvm/Instruction.h
@@ -200,11 +200,10 @@ public:
///
/// 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, when
- /// not applied to floating point types.
+ /// In LLVM, the Add, Mul, And, Or, and Xor operators are associative.
///
- bool isAssociative() const { return isAssociative(getOpcode(), getType()); }
- static bool isAssociative(unsigned op, const Type *Ty);
+ bool isAssociative() const { return isAssociative(getOpcode()); }
+ static bool isAssociative(unsigned op);
/// isCommutative - Return true if the instruction is commutative:
///
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp
index 2309f2274b..5c284b746d 100644
--- a/lib/VMCore/ConstantFold.cpp
+++ b/lib/VMCore/ConstantFold.cpp
@@ -1338,8 +1338,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode,
// Given ((a + b) + c), if (b + c) folds to something interesting, return
// (a + (b + c)).
- if (Instruction::isAssociative(Opcode, C1->getType()) &&
- CE1->getOpcode() == Opcode) {
+ if (Instruction::isAssociative(Opcode) && CE1->getOpcode() == Opcode) {
Constant *T = ConstantExpr::get(Opcode, CE1->getOperand(1), C2);
if (!isa<ConstantExpr>(T) || cast<ConstantExpr>(T)->getOpcode() != Opcode)
return ConstantExpr::get(Opcode, CE1->getOperand(0), T);
diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp
index fdddba988c..7bb2cf167b 100644
--- a/lib/VMCore/Instruction.cpp
+++ b/lib/VMCore/Instruction.cpp
@@ -348,7 +348,7 @@ bool Instruction::mayThrow() const {
///
/// In LLVM, the Add, Mul, And, Or, and Xor operators are associative.
///
-bool Instruction::isAssociative(unsigned Opcode, const Type *Ty) {
+bool Instruction::isAssociative(unsigned Opcode) {
return Opcode == And || Opcode == Or || Opcode == Xor ||
Opcode == Add || Opcode == Mul;
}