Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit e271f8c

Browse files
committed
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@325607 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 1837dbf commit e271f8c

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

include/llvm/IR/IRBuilder.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ class IRBuilderBase {
676676

677677
/// Create call to the maxnum intrinsic.
678678
CallInst *CreateMaxNum(Value *LHS, Value *RHS, const Twine &Name = "") {
679-
return CreateBinaryIntrinsic(Intrinsic::minnum, LHS, RHS, Name);
679+
return CreateBinaryIntrinsic(Intrinsic::maxnum, LHS, RHS, Name);
680680
}
681681

682682
private:

unittests/IR/IRBuilderTest.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,23 @@ class IRBuilderTest : public testing::Test {
4848
GlobalVariable *GV;
4949
};
5050

51+
TEST_F(IRBuilderTest, Intrinsics) {
52+
IRBuilder<> Builder(BB);
53+
Value *V;
54+
CallInst *Call;
55+
IntrinsicInst *II;
56+
57+
V = Builder.CreateLoad(GV);
58+
59+
Call = Builder.CreateMinNum(V, V);
60+
II = cast<IntrinsicInst>(Call);
61+
EXPECT_EQ(II->getIntrinsicID(), Intrinsic::minnum);
62+
63+
Call = Builder.CreateMaxNum(V, V);
64+
II = cast<IntrinsicInst>(Call);
65+
EXPECT_EQ(II->getIntrinsicID(), Intrinsic::maxnum);
66+
}
67+
5168
TEST_F(IRBuilderTest, Lifetime) {
5269
IRBuilder<> Builder(BB);
5370
AllocaInst *Var1 = Builder.CreateAlloca(Builder.getInt8Ty());

0 commit comments

Comments
 (0)