[CodeGenPrepare] Pre-commit debug info test for optimizeSelectInst
authorVedant Kumar <vsk@apple.com>
Tue, 21 Aug 2018 23:42:53 +0000 (23:42 +0000)
committerVedant Kumar <vsk@apple.com>
Tue, 21 Aug 2018 23:42:53 +0000 (23:42 +0000)
This test shows that optimizeSelectInst splits a select and sinks a
`fdiv` operation to one side of the diamond. However, the dbg.value for
the operation isn't moved.

llvm-svn: 340369

llvm/test/Transforms/CodeGenPrepare/X86/select.ll

index 58d81b5..9abb286 100644 (file)
@@ -1,5 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt -codegenprepare -S < %s | FileCheck %s
+; RUN: opt -debugify -codegenprepare -S < %s | FileCheck %s -check-prefix=DEBUG
 
 target triple = "x86_64-unknown-unknown"
 
@@ -35,6 +36,20 @@ define float @fdiv_true_sink(float %a, float %b) {
 ; CHECK-NEXT:    [[SEL:%.*]] = phi float [ [[DIV]], [[SELECT_TRUE_SINK]] ], [ 2.000000e+00, [[ENTRY:%.*]] ]
 ; CHECK-NEXT:    ret float [[SEL]]
 ;
+; DEBUG-LABEL: @fdiv_true_sink(
+; DEBUG-NEXT:  entry:
+; DEBUG-NEXT:    call void @llvm.dbg.value(metadata float [[DIV:%[^,]+]]
+; DEBUG-NEXT:    [[CMP:%.*]] = fcmp ogt float [[A:%.*]], 1.000000e+00
+; DEBUG-NEXT:    call void @llvm.dbg.value(metadata i1 [[CMP]]
+; DEBUG-NEXT:    br i1 [[CMP]], label [[SELECT_TRUE_SINK:%.*]], label [[SELECT_END:%[^,]+]]
+; DEBUG:       select.true.sink:
+; DEBUG-NEXT:    [[DIV]] = fdiv float [[A]], [[B:%.*]]
+; DEBUG-NEXT:    br label [[SELECT_END]]
+; DEBUG:       select.end:
+; DEBUG-NEXT:    [[SEL:%.*]] = phi float [ [[DIV]], [[SELECT_TRUE_SINK]] ], [ 2.000000e+00, [[ENTRY:%.*]] ]
+; DEBUG-NEXT:    call void @llvm.dbg.value(metadata float [[SEL]]
+; DEBUG-NEXT:    ret float [[SEL]]
+;
 entry:
   %div = fdiv float %a, %b
   %cmp = fcmp ogt float %a, 1.0