[PATCH] D53650: [FPEnv] Last BinaryOperator::isFNeg(...) to m_FNeg(...) changes
Cameron McInally via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 25 08:05:51 PDT 2018
cameron.mcinally updated this revision to Diff 171100.
cameron.mcinally added a comment.
Updating diff based on Sanjay's suggestions. One comment inline...
Repository:
rL LLVM
https://reviews.llvm.org/D53650
Files:
lib/CodeGen/SelectionDAG/FastISel.cpp
lib/Transforms/InstCombine/InstCombineCasts.cpp
Index: lib/Transforms/InstCombine/InstCombineCasts.cpp
===================================================================
--- lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -1612,8 +1612,9 @@
}
// (fptrunc (fneg x)) -> (fneg (fptrunc x))
- if (BinaryOperator::isFNeg(OpI)) {
- Value *InnerTrunc = Builder.CreateFPTrunc(OpI->getOperand(1), Ty);
+ Value *X;
+ 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"
@@ -1692,7 +1694,10 @@
/// Emit an FNeg operation.
bool FastISel::selectFNeg(const User *I) {
- unsigned OpReg = getRegForValue(BinaryOperator::getFNegArgument(I));
+ Value *X;
+ if (!match(I, m_FNeg(m_Value(X))))
+ return false;
+ unsigned OpReg = getRegForValue(X);
if (!OpReg)
return false;
bool OpRegIsKill = hasTrivialKill(I);
@@ -1782,11 +1787,9 @@
return selectBinaryOp(I, ISD::FADD);
case Instruction::Sub:
return selectBinaryOp(I, ISD::SUB);
- case Instruction::FSub:
+ case Instruction::FSub:
// FNeg is currently represented in LLVM IR as a special case of FSub.
- if (BinaryOperator::isFNeg(I))
- return selectFNeg(I);
- return selectBinaryOp(I, ISD::FSUB);
+ return selectFNeg(I) || selectBinaryOp(I, ISD::FSUB);
case Instruction::Mul:
return selectBinaryOp(I, ISD::MUL);
case Instruction::FMul:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53650.171100.patch
Type: text/x-patch
Size: 2038 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181025/df0159da/attachment.bin>
More information about the llvm-commits
mailing list