aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ConstantFolding.cpp
diff options
context:
space:
mode:
authorBjorn Pettersson <bjorn.a.pettersson@ericsson.com>2019-06-24 12:07:17 +0000
committerBjorn Pettersson <bjorn.a.pettersson@ericsson.com>2019-06-24 12:07:17 +0000
commit485a421876d744a26fa1afffa00cf4ee625ef5df (patch)
treeb29f0b61b2985e4c171cc4964e084687b8aa348b /llvm/lib/Analysis/ConstantFolding.cpp
parent512b1187794d33c75e4d88e8a4822aab375379c0 (diff)
downloadllvm-485a421876d744a26fa1afffa00cf4ee625ef5df.zip
llvm-485a421876d744a26fa1afffa00cf4ee625ef5df.tar.gz
llvm-485a421876d744a26fa1afffa00cf4ee625ef5df.tar.bz2
[ConstantFolding] Use hasVectorInstrinsicScalarOpd. NFC
Summary: Use the hasVectorInstrinsicScalarOpd helper function in ConstantFoldVectorCall. Reviewers: rengolin, RKSimon, dblaikie Reviewed By: rengolin, RKSimon Subscribers: tschuett, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D63705 llvm-svn: 364178
Diffstat (limited to 'llvm/lib/Analysis/ConstantFolding.cpp')
-rw-r--r--llvm/lib/Analysis/ConstantFolding.cpp29
1 files changed, 13 insertions, 16 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 9372904..a512834 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -25,6 +25,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/ValueTracking.h"
+#include "llvm/Analysis/VectorUtils.h"
#include "llvm/Config/config.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h"
@@ -1649,7 +1650,8 @@ static bool getConstIntOrUndef(Value *Op, const APInt *&C) {
return false;
}
-static Constant *ConstantFoldScalarCall1(StringRef Name, unsigned IntrinsicID,
+static Constant *ConstantFoldScalarCall1(StringRef Name,
+ Intrinsic::ID IntrinsicID,
Type *Ty,
ArrayRef<Constant *> Operands,
const TargetLibraryInfo *TLI,
@@ -1943,7 +1945,8 @@ static Constant *ConstantFoldScalarCall1(StringRef Name, unsigned IntrinsicID,
return nullptr;
}
-static Constant *ConstantFoldScalarCall2(StringRef Name, unsigned IntrinsicID,
+static Constant *ConstantFoldScalarCall2(StringRef Name,
+ Intrinsic::ID IntrinsicID,
Type *Ty,
ArrayRef<Constant *> Operands,
const TargetLibraryInfo *TLI,
@@ -2172,7 +2175,8 @@ static Constant *ConstantFoldScalarCall2(StringRef Name, unsigned IntrinsicID,
return nullptr;
}
-static Constant *ConstantFoldScalarCall3(StringRef Name, unsigned IntrinsicID,
+static Constant *ConstantFoldScalarCall3(StringRef Name,
+ Intrinsic::ID IntrinsicID,
Type *Ty,
ArrayRef<Constant *> Operands,
const TargetLibraryInfo *TLI,
@@ -2270,7 +2274,8 @@ static Constant *ConstantFoldScalarCall3(StringRef Name, unsigned IntrinsicID,
return nullptr;
}
-static Constant *ConstantFoldScalarCall(StringRef Name, unsigned IntrinsicID,
+static Constant *ConstantFoldScalarCall(StringRef Name,
+ Intrinsic::ID IntrinsicID,
Type *Ty,
ArrayRef<Constant *> Operands,
const TargetLibraryInfo *TLI,
@@ -2287,7 +2292,8 @@ static Constant *ConstantFoldScalarCall(StringRef Name, unsigned IntrinsicID,
return nullptr;
}
-static Constant *ConstantFoldVectorCall(StringRef Name, unsigned IntrinsicID,
+static Constant *ConstantFoldVectorCall(StringRef Name,
+ Intrinsic::ID IntrinsicID,
VectorType *VTy,
ArrayRef<Constant *> Operands,
const DataLayout &DL,
@@ -2339,17 +2345,8 @@ static Constant *ConstantFoldVectorCall(StringRef Name, unsigned IntrinsicID,
for (unsigned I = 0, E = VTy->getNumElements(); I != E; ++I) {
// Gather a column of constants.
for (unsigned J = 0, JE = Operands.size(); J != JE; ++J) {
- // These intrinsics use a scalar type for their second argument.
- if (J == 1 &&
- (IntrinsicID == Intrinsic::cttz || IntrinsicID == Intrinsic::ctlz ||
- IntrinsicID == Intrinsic::powi)) {
- Lane[J] = Operands[J];
- continue;
- }
- // These intrinsics use a scalar type for their third argument.
- if (J == 2 &&
- (IntrinsicID == Intrinsic::smul_fix ||
- IntrinsicID == Intrinsic::smul_fix_sat)) {
+ // Some intrinsics use a scalar type for certain arguments.
+ if (hasVectorInstrinsicScalarOpd(IntrinsicID, J)) {
Lane[J] = Operands[J];
continue;
}