[PATCH] D53205: [FPEnv][NFCI] Convert more BinaryOperator::isFNeg(...) to m_FNeg(...)

Cameron McInally via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 12 09:54:39 PDT 2018


cameron.mcinally created this revision.
cameron.mcinally added reviewers: spatel, craig.topper, andrew.w.kaylor, uweigand, kpn.
Herald added a subscriber: llvm-commits.

Continuing the work started in https://reviews.llvm.org/D52934...

This patch replaces more uses of BinaryOperator::isFNeg(...) with the more general m_FNeg(...).

Please excuse the small patch, I wanted to run a design decision passed @spatel before proceeding. Sanjay, please note the inline comment.


Repository:
  rL LLVM

https://reviews.llvm.org/D53205

Files:
  lib/CodeGen/SelectionDAG/FastISel.cpp
  lib/Transforms/InstCombine/InstCombineCasts.cpp
  lib/Transforms/InstCombine/InstCombineInternal.h


Index: lib/Transforms/InstCombine/InstCombineInternal.h
===================================================================
--- lib/Transforms/InstCombine/InstCombineInternal.h
+++ lib/Transforms/InstCombine/InstCombineInternal.h
@@ -83,7 +83,7 @@
 static inline unsigned getComplexity(Value *V) {
   if (isa<Instruction>(V)) {
     if (isa<CastInst>(V) || BinaryOperator::isNeg(V) ||
-        BinaryOperator::isFNeg(V) || BinaryOperator::isNot(V))
+        match(V, m_FNeg(m_Value())) || BinaryOperator::isNot(V))
       return 4;
     return 5;
   }
Index: lib/Transforms/InstCombine/InstCombineCasts.cpp
===================================================================
--- lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -1611,9 +1611,10 @@
       }
     }
 
+    Value *X;
     // (fptrunc (fneg x)) -> (fneg (fptrunc x))
-    if (BinaryOperator::isFNeg(OpI)) {
-      Value *InnerTrunc = Builder.CreateFPTrunc(OpI->getOperand(1), Ty);
+    if (match(OpI, m_FNeg(m_Value(X)))) {
+      Value *InnerTrunc = Builder.CreateFPTrunc(X, Ty);
       return BinaryOperator::CreateFNegFMF(InnerTrunc, OpI);
     }
   }
Index: lib/CodeGen/SelectionDAG/FastISel.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/FastISel.cpp
+++ lib/CodeGen/SelectionDAG/FastISel.cpp
@@ -89,6 +89,7 @@
 #include "llvm/IR/Mangler.h"
 #include "llvm/IR/Metadata.h"
 #include "llvm/IR/Operator.h"
+#include "llvm/IR/PatternMatch.h"
 #include "llvm/IR/Type.h"
 #include "llvm/IR/User.h"
 #include "llvm/IR/Value.h"
@@ -110,6 +111,7 @@
 #include <utility>
 
 using namespace llvm;
+using namespace PatternMatch;
 
 #define DEBUG_TYPE "isel"
 
@@ -1784,7 +1786,7 @@
     return selectBinaryOp(I, ISD::SUB);
   case Instruction::FSub:
     // FNeg is currently represented in LLVM IR as a special case of FSub.
-    if (BinaryOperator::isFNeg(I))
+    if (match(I, m_FNeg(m_Value())))
       return selectFNeg(I);
     return selectBinaryOp(I, ISD::FSUB);
   case Instruction::Mul:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53205.169443.patch
Type: text/x-patch
Size: 2060 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181012/755945ec/attachment.bin>


More information about the llvm-commits mailing list