[llvm] r318298 - [Reassociate] simplify code; NFCI

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 15 08:19:17 PST 2017


Author: spatel
Date: Wed Nov 15 08:19:17 2017
New Revision: 318298

URL: http://llvm.org/viewvc/llvm-project?rev=318298&view=rev
Log:
[Reassociate] simplify code; NFCI

Modified:
    llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp?rev=318298&r1=318297&r2=318298&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/Reassociate.cpp Wed Nov 15 08:19:17 2017
@@ -798,12 +798,9 @@ void ReassociatePass::RewriteExprTree(Bi
 /// additional opportunities have been exposed.
 static Value *NegateValue(Value *V, Instruction *BI,
                           SetVector<AssertingVH<Instruction>> &ToRedo) {
-  if (Constant *C = dyn_cast<Constant>(V)) {
-    if (C->getType()->isFPOrFPVectorTy()) {
-      return ConstantExpr::getFNeg(C);
-    }
-    return ConstantExpr::getNeg(C);
-  }
+  if (auto *C = dyn_cast<Constant>(V))
+    return C->getType()->isFPOrFPVectorTy() ? ConstantExpr::getFNeg(C) :
+                                              ConstantExpr::getNeg(C);
 
   // We are trying to expose opportunity for reassociation.  One of the things
   // that we want to do to achieve this is to push a negation as deep into an




More information about the llvm-commits mailing list