From d99df68e19be0c941fb4eff0a18c482a8e4a22f7 Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Fri, 14 Nov 2014 17:08:15 +0000 Subject: [Reassociate] Canonicalize operands of vector binary operators. Prior to this commit fmul and fadd binary operators were being canonicalized for both scalar and vector versions. We now canonicalize add, mul, and, or, and xor vector instructions. llvm-svn: 222006 --- llvm/lib/Transforms/Scalar/Reassociate.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'llvm/lib/Transforms/Scalar/Reassociate.cpp') diff --git a/llvm/lib/Transforms/Scalar/Reassociate.cpp b/llvm/lib/Transforms/Scalar/Reassociate.cpp index 42e7aac..67659bb 100644 --- a/llvm/lib/Transforms/Scalar/Reassociate.cpp +++ b/llvm/lib/Transforms/Scalar/Reassociate.cpp @@ -2083,14 +2083,9 @@ void Reassociate::OptimizeInst(Instruction *I) { // writing other transformations simpler. if (I->getType()->isFloatingPointTy() || I->getType()->isVectorTy()) { - // FAdd and FMul can be commuted. - unsigned Opcode = I->getOpcode(); - if (Opcode == Instruction::FMul || Opcode == Instruction::FAdd) + if (I->isCommutative()) canonicalizeOperands(I); - // FIXME: We should commute vector instructions as well. However, this - // requires further analysis to determine the effect on later passes. - // Don't try to optimize vector instructions or anything that doesn't have // unsafe algebra. if (I->getType()->isVectorTy() || !I->hasUnsafeAlgebra()) -- cgit v1.1