[InstCombine] don't drop metadata in FoldOpIntoSelect()

llvm-svn: 287980
This commit is contained in:
Sanjay Patel 2016-11-26 15:23:20 +00:00
parent e8a077badf
commit 8bd69b7ed9
2 changed files with 14 additions and 3 deletions

View File

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

View File

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