[llvm] r287980 - [InstCombine] don't drop metadata in FoldOpIntoSelect()
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 26 07:23:21 PST 2016
Author: spatel
Date: Sat Nov 26 09:23:20 2016
New Revision: 287980
URL: http://llvm.org/viewvc/llvm-project?rev=287980&view=rev
Log:
[InstCombine] don't drop metadata in FoldOpIntoSelect()
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/trunk/test/Transforms/InstCombine/select_meta.ll
Modified: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp?rev=287980&r1=287979&r2=287980&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp Sat Nov 26 09:23:20 2016
@@ -819,9 +819,9 @@ Instruction *InstCombiner::FoldOpIntoSel
}
}
- 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
Modified: llvm/trunk/test/Transforms/InstCombine/select_meta.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/select_meta.ll?rev=287980&r1=287979&r2=287980&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/select_meta.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/select_meta.ll Sat Nov 26 09:23:20 2016
@@ -17,6 +17,17 @@ define i32 @foo(i32) local_unnamed_addr
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
More information about the llvm-commits
mailing list