summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2018-02-20 18:21:43 +0000
committerSanjay Patel <spatel@rotateright.com>2018-02-20 18:21:43 +0000
commita6043700049e8de7a8eae1fe5cd64a360d6f4426 (patch)
treed84cc3259e12b0428886be0a405209b8542cef2b
parentf9f2005f9426e860c090475e04983e95d6ba04e6 (diff)
downloadbcm5719-llvm-a6043700049e8de7a8eae1fe5cd64a360d6f4426.tar.gz
bcm5719-llvm-a6043700049e8de7a8eae1fe5cd64a360d6f4426.zip
[IRBuilder] fix CreateMaxNum to actually produce maxnum (PR36454)
The bug was introduced here: https://reviews.llvm.org/rL296409 ...but the patch doesn't use maxnum and nothing else in trunk has tried since then, so the bug went unnoticed. llvm-svn: 325607
-rw-r--r--llvm/include/llvm/IR/IRBuilder.h2
-rw-r--r--llvm/unittests/IR/IRBuilderTest.cpp17
2 files changed, 18 insertions, 1 deletions
diff --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h
index 97a36ce4cdc..ab9b5c549df 100644
--- a/llvm/include/llvm/IR/IRBuilder.h
+++ b/llvm/include/llvm/IR/IRBuilder.h
@@ -676,7 +676,7 @@ public:
/// Create call to the maxnum intrinsic.
CallInst *CreateMaxNum(Value *LHS, Value *RHS, const Twine &Name = "") {
- return CreateBinaryIntrinsic(Intrinsic::minnum, LHS, RHS, Name);
+ return CreateBinaryIntrinsic(Intrinsic::maxnum, LHS, RHS, Name);
}
private:
diff --git a/llvm/unittests/IR/IRBuilderTest.cpp b/llvm/unittests/IR/IRBuilderTest.cpp
index bb74756d81a..6a3d121552d 100644
--- a/llvm/unittests/IR/IRBuilderTest.cpp
+++ b/llvm/unittests/IR/IRBuilderTest.cpp
@@ -48,6 +48,23 @@ protected:
GlobalVariable *GV;
};
+TEST_F(IRBuilderTest, Intrinsics) {
+ IRBuilder<> Builder(BB);
+ Value *V;
+ CallInst *Call;
+ IntrinsicInst *II;
+
+ V = Builder.CreateLoad(GV);
+
+ Call = Builder.CreateMinNum(V, V);
+ II = cast<IntrinsicInst>(Call);
+ EXPECT_EQ(II->getIntrinsicID(), Intrinsic::minnum);
+
+ Call = Builder.CreateMaxNum(V, V);
+ II = cast<IntrinsicInst>(Call);
+ EXPECT_EQ(II->getIntrinsicID(), Intrinsic::maxnum);
+}
+
TEST_F(IRBuilderTest, Lifetime) {
IRBuilder<> Builder(BB);
AllocaInst *Var1 = Builder.CreateAlloca(Builder.getInt8Ty());
OpenPOWER on IntegriCloud