[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
This commit is contained in:
Sanjay Patel 2018-02-20 18:21:43 +00:00
parent f9f2005f94
commit a604370004
2 changed files with 18 additions and 1 deletions

View File

@ -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:

View File

@ -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());