diff --git a/llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp b/llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp index 9b9e2bac5db32..9150b58d0acf1 100644 --- a/llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp +++ b/llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp @@ -459,7 +459,7 @@ void TruncInstCombine::ReduceExpressionGraph(Type *SclTy) { Value *Op0 = I->getOperand(0); Value *LHS = getReducedOperand(I->getOperand(1), SclTy); Value *RHS = getReducedOperand(I->getOperand(2), SclTy); - Res = Builder.CreateSelect(Op0, LHS, RHS); + Res = Builder.CreateSelect(Op0, LHS, RHS, "", I); break; } case Instruction::PHI: { diff --git a/llvm/test/Transforms/AggressiveInstCombine/trunc_select.ll b/llvm/test/Transforms/AggressiveInstCombine/trunc_select.ll index fb147821889db..93522119340e3 100644 --- a/llvm/test/Transforms/AggressiveInstCombine/trunc_select.ll +++ b/llvm/test/Transforms/AggressiveInstCombine/trunc_select.ll @@ -3,16 +3,17 @@ target datalayout = "e-m:m-p1:64:64:64-p:32:32:32-n8:16:32" -define dso_local i16 @select_i16(i16 %a, i16 %b, i1 %cond) { +define dso_local i16 @select_i16(i16 %a, i16 %b, i1 %cond) !prof !0 { ; CHECK-LABEL: @select_i16( +; CHECK: !prof [[PROF_0:![0-9]+]] { ; CHECK-NEXT: entry: -; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], i16 [[A:%.*]], i16 [[B:%.*]] +; CHECK-NEXT: [[SEL:%.*]] = select i1 [[COND:%.*]], i16 [[A:%.*]], i16 [[B:%.*]], !prof [[PROF_1:![0-9]+]] ; CHECK-NEXT: ret i16 [[SEL]] ; entry: %conv0 = sext i16 %a to i32 %conv1 = sext i16 %b to i32 - %sel = select i1 %cond, i32 %conv0, i32 %conv1 + %sel = select i1 %cond, i32 %conv0, i32 %conv1, !prof !1 %conv4 = trunc i32 %sel to i16 ret i16 %conv4 } @@ -134,3 +135,8 @@ entry: ret i16 %conv4 } +!0 = !{!"function_entry_count", i64 1000} +!1 = !{!"branch_weights", i32 2, i32 3} +; CHECK: [[PROF_0]] = !{!"function_entry_count", i64 1000} +; CHECK: [[PROF_1]] = !{!"branch_weights", i32 2, i32 3} + diff --git a/llvm/test/Transforms/AggressiveInstCombine/trunc_select_cmp.ll b/llvm/test/Transforms/AggressiveInstCombine/trunc_select_cmp.ll index ac9cf2dbd89b8..69ad6258e9cd8 100644 --- a/llvm/test/Transforms/AggressiveInstCombine/trunc_select_cmp.ll +++ b/llvm/test/Transforms/AggressiveInstCombine/trunc_select_cmp.ll @@ -1,19 +1,20 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt < %s -passes=aggressive-instcombine -S | FileCheck %s -define dso_local i16 @cmp_select_sext_const(i8 %a) { +define dso_local i16 @cmp_select_sext_const(i8 %a) !prof !0 { ; CHECK-LABEL: @cmp_select_sext_const( +; CHECK: !prof [[PROF_0:![0-9]+]] { ; CHECK-NEXT: entry: ; CHECK-NEXT: [[CONV:%.*]] = sext i8 [[A:%.*]] to i32 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[CONV]], 109 -; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 109, i32 [[CONV]] +; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], i32 109, i32 [[CONV]], !prof [[PROF_1:![0-9]+]] ; CHECK-NEXT: [[CONV4:%.*]] = trunc i32 [[COND]] to i16 ; CHECK-NEXT: ret i16 [[CONV4]] ; entry: %conv = sext i8 %a to i32 %cmp = icmp slt i32 %conv, 109 - %cond = select i1 %cmp, i32 109, i32 %conv + %cond = select i1 %cmp, i32 109, i32 %conv, !prof !1 %conv4 = trunc i32 %cond to i16 ret i16 %conv4 } @@ -209,3 +210,7 @@ define i16 @cmp_select_unsigned_const_i16Const_noTransformation(i8 %a) { ret i16 %conv4 } +!0 = !{!"function_entry_count", i64 1000} +!1 = !{!"branch_weights", i32 2, i32 3} +; CHECK: [[PROF_0]] = !{!"function_entry_count", i64 1000} +; CHECK: [[PROF_1]] = !{!"branch_weights", i32 2, i32 3}