[PATCH] D49270: [InstCombine] Preserve debug value when simplifying cast-of-select
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 17 11:13:46 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL337310: [InstCombine] Preserve debug value when simplifying cast-of-select (authored by vedantk, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D49270?vs=155282&id=155926#toc
Repository:
rL LLVM
https://reviews.llvm.org/D49270
Files:
llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp
llvm/trunk/test/Transforms/InstCombine/debuginfo-variables.ll
Index: llvm/trunk/test/Transforms/InstCombine/debuginfo-variables.ll
===================================================================
--- llvm/trunk/test/Transforms/InstCombine/debuginfo-variables.ll
+++ llvm/trunk/test/Transforms/InstCombine/debuginfo-variables.ll
@@ -26,6 +26,17 @@
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))
Index: llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp
===================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -282,8 +282,10 @@
// 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49270.155926.patch
Type: text/x-patch
Size: 1702 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180717/3205ffbe/attachment.bin>
More information about the llvm-commits
mailing list