diff options
author | Sanjay Patel <spatel@rotateright.com> | 2016-11-26 15:23:20 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2016-11-26 15:23:20 +0000 |
commit | 8bd69b7ed9fb4e9d815326b3cfd507584e98c7ad (patch) | |
tree | c0352c1d6ee34885d89ef5d3b1a8bd7b0ef62273 | |
parent | e8a077badf852530077c8abda9d9d1737b44140c (diff) | |
download | bcm5719-llvm-8bd69b7ed9fb4e9d815326b3cfd507584e98c7ad.tar.gz bcm5719-llvm-8bd69b7ed9fb4e9d815326b3cfd507584e98c7ad.zip |
[InstCombine] don't drop metadata in FoldOpIntoSelect()
llvm-svn: 287980
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstructionCombining.cpp | 6 | ||||
-rw-r--r-- | llvm/test/Transforms/InstCombine/select_meta.ll | 11 |
2 files changed, 14 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp index 2529c473554..cdbc8eb4585 100644 --- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -819,9 +819,9 @@ Instruction *InstCombiner::FoldOpIntoSelect(Instruction &Op, SelectInst *SI) { } } - Value *SelectTVal = foldOperationIntoSelectOperand(Op, TV, this); - Value *SelectFVal = foldOperationIntoSelectOperand(Op, FV, this); - return SelectInst::Create(SI->getCondition(), SelectTVal, SelectFVal); + Value *NewTV = foldOperationIntoSelectOperand(Op, TV, this); + Value *NewFV = foldOperationIntoSelectOperand(Op, FV, this); + return SelectInst::Create(SI->getCondition(), NewTV, NewFV, "", nullptr, SI); } /// Given a binary operator, cast instruction, or select which has a PHI node as diff --git a/llvm/test/Transforms/InstCombine/select_meta.ll b/llvm/test/Transforms/InstCombine/select_meta.ll index 27c0c1c309c..82a85e5836d 100644 --- a/llvm/test/Transforms/InstCombine/select_meta.ll +++ b/llvm/test/Transforms/InstCombine/select_meta.ll @@ -17,6 +17,17 @@ define i32 @foo(i32) local_unnamed_addr #0 { ret i32 %5 } +define i8 @shrink_select(i1 %cond, i32 %x) { +; CHECK-LABEL: @shrink_select( +; CHECK-NEXT: [[TMP1:%.*]] = trunc i32 %x to i8 +; CHECK-NEXT: [[TRUNC:%.*]] = select i1 %cond, i8 [[TMP1]], i8 42, !prof ![[MD1]] +; CHECK-NEXT: ret i8 [[TRUNC]] +; + %sel = select i1 %cond, i32 %x, i32 42, !prof !1 + %trunc = trunc i32 %sel to i8 + ret i8 %trunc +} + define void @min_max_bitcast(<4 x float> %a, <4 x float> %b, <4 x i32>* %ptr1, <4 x i32>* %ptr2) { ; CHECK-LABEL: @min_max_bitcast( ; CHECK-NEXT: [[CMP:%.*]] = fcmp olt <4 x float> %a, %b |