diff options
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp | 4 | ||||
| -rw-r--r-- | llvm/test/Transforms/InstCombine/debuginfo-variables.ll | 11 |
2 files changed, 14 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp index 481e40612c3..e8ea7396a96 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp @@ -282,8 +282,10 @@ Instruction *InstCombiner::commonCastTransforms(CastInst &CI) { // condition may inhibit other folds and lead to worse codegen. auto *Cmp = dyn_cast<CmpInst>(Sel->getCondition()); if (!Cmp || Cmp->getOperand(0)->getType() != Sel->getType()) - if (Instruction *NV = FoldOpIntoSelect(CI, Sel)) + if (Instruction *NV = FoldOpIntoSelect(CI, Sel)) { + replaceAllDbgUsesWith(*Sel, *NV, CI, DT); return NV; + } } // If we are casting a PHI, then fold the cast into the PHI. diff --git a/llvm/test/Transforms/InstCombine/debuginfo-variables.ll b/llvm/test/Transforms/InstCombine/debuginfo-variables.ll index d277b6c3233..dcb07d5e678 100644 --- a/llvm/test/Transforms/InstCombine/debuginfo-variables.ll +++ b/llvm/test/Transforms/InstCombine/debuginfo-variables.ll @@ -26,6 +26,17 @@ define i64 @test_used_sext_zext(i16 %A) { ret i64 %c2 } +define i32 @test_cast_select(i1 %cond) { +; CHECK-LABEL: @test_cast_select( +; CHECK-NEXT: [[sel:%.*]] = select i1 %cond, i32 3, i32 5 +; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 [[sel]], {{.*}}, metadata !DIExpression()) +; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 [[sel]], {{.*}}, metadata !DIExpression()) +; CHECK-NEXT: ret i32 [[sel]] + %sel = select i1 %cond, i16 3, i16 5 + %cast = zext i16 %sel to i32 + ret i32 %cast +} + define void @test_or(i64 %A) { ; CHECK-LABEL: @test_or( ; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_constu, 256, DW_OP_or, DW_OP_stack_value)) |

