summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2016-11-26 15:01:59 +0000
committerSanjay Patel <spatel@rotateright.com>2016-11-26 15:01:59 +0000
commit91e73a7bfaed49fb3e1f9d1d3fd30e40afb114a1 (patch)
treef0675540616beff3e4374d4e148916781d3298be /llvm/lib
parent10d5eec1a1615dcd3a4156041ae5e5a709d8679e (diff)
downloadbcm5719-llvm-91e73a7bfaed49fb3e1f9d1d3fd30e40afb114a1.tar.gz
bcm5719-llvm-91e73a7bfaed49fb3e1f9d1d3fd30e40afb114a1.zip
add optional param to copy metadata when creating selects; NFC
There are other spots where we can use this; we're currently dropping metadata in some places, and there are proposed changes where we will want to propagate metadata. IRBuilder's CreateSelect() already has a parameter like this, so this change makes the regular 'Create' API line up with that. llvm-svn: 287976
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp10
1 files changed, 3 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
index 98b92970566..36644845352 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
@@ -531,8 +531,7 @@ canonicalizeMinMaxWithConstant(SelectInst &Sel, ICmpInst &Cmp,
std::swap(LHS, RHS);
Value *NewCmp = Builder.CreateICmp(NewPred, LHS, RHS);
- SelectInst *NewSel = SelectInst::Create(NewCmp, LHS, RHS);
- NewSel->copyMetadata(Sel);
+ SelectInst *NewSel = SelectInst::Create(NewCmp, LHS, RHS, "", nullptr, &Sel);
// We swapped the select operands, so swap the metadata too.
NewSel->swapProfMetadata();
@@ -995,21 +994,18 @@ Instruction *InstCombiner::foldSelectExtConst(SelectInst &Sel) {
// If one arm of the select is the extend of the condition, replace that arm
// with the extension of the appropriate known bool value.
if (Cond == X) {
- SelectInst *NewSel;
if (ExtInst == Sel.getTrueValue()) {
// select X, (sext X), C --> select X, -1, C
// select X, (zext X), C --> select X, 1, C
Constant *One = ConstantInt::getTrue(SmallType);
Constant *AllOnesOrOne = ConstantExpr::getCast(ExtOpcode, One, SelType);
- NewSel = SelectInst::Create(Cond, AllOnesOrOne, C);
+ return SelectInst::Create(Cond, AllOnesOrOne, C, "", nullptr, &Sel);
} else {
// select X, C, (sext X) --> select X, C, 0
// select X, C, (zext X) --> select X, C, 0
Constant *Zero = ConstantInt::getNullValue(SelType);
- NewSel = SelectInst::Create(Cond, C, Zero);
+ return SelectInst::Create(Cond, C, Zero, "", nullptr, &Sel);
}
- NewSel->copyMetadata(Sel);
- return NewSel;
}
return nullptr;
OpenPOWER on IntegriCloud