llvm/llvm/test/CodeGen/X86/licm-dominance.ll

; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --force-update
; RUN: llc -asm-verbose=true < %s | FileCheck %s

; MachineLICM should check dominance before hoisting instructions.
; only the load of a0 is guaranteed to execute, so only it can be hoisted.

target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
target triple = "x86_64-apple-macosx10.7.2"

define void @CMSColorWorldCreateParametricData(
; CHECK-LABEL: CMSColorWorldCreateParametricData:
; CHECK:       ## %bb.0: ## %entry
; CHECK-NEXT:    xorl %eax, %eax
; CHECK-NEXT:    movb (%rdi), %dil
; CHECK-NEXT:  LBB0_1: ## %for.body.i
; CHECK-NEXT:    ## =>This Inner Loop Header: Depth=1
; CHECK-NEXT:    testb %dil, %dil
; CHECK-NEXT:    je LBB0_5
; CHECK-NEXT:  ## %bb.2: ## %if.then26.i
; CHECK-NEXT:    ## in Loop: Header=BB0_1 Depth=1
; CHECK-NEXT:    cmpb $1, (%rsi)
; CHECK-NEXT:    jne LBB0_4
; CHECK-NEXT:  ## %bb.3: ## %if.else.i.i
; CHECK-NEXT:    ## in Loop: Header=BB0_1 Depth=1
; CHECK-NEXT:    cmpb $2, (%rdx)
; CHECK-NEXT:    jne LBB0_5
; CHECK-NEXT:  LBB0_4: ## %lor.lhs.false.i.i
; CHECK-NEXT:    ## in Loop: Header=BB0_1 Depth=1
; CHECK-NEXT:    cmpb $3, (%rcx)
; CHECK-NEXT:    jne LBB0_6
; CHECK-NEXT:  LBB0_5: ## %for.inc.i
; CHECK-NEXT:    ## in Loop: Header=BB0_1 Depth=1
; CHECK-NEXT:    incq %rax
; CHECK-NEXT:    cmpq %r8, %rax
; CHECK-NEXT:    jb LBB0_1
; CHECK-NEXT:  LBB0_6: ## %if.end28.i
; CHECK-NEXT:    retq
  ptr dereferenceable(1) %a0,
  ptr dereferenceable(1) %a1,
  ptr dereferenceable(1) %a2,
  ptr dereferenceable(1) %a3,
  i64 %count) nounwind uwtable optsize ssp readonly nofree nosync {
entry:
  br label %for.body.i

for.body.i:
  %i = phi i64 [0, %entry], [%i.inc, %for.inc.i]
  %0 = load i8, ptr %a0, !invariant.load !0
  %cond0 = icmp eq i8 %0, 0
  br i1 %cond0, label %for.inc.i, label %if.then26.i

if.then26.i:
  %1 = load i8, ptr %a1, !invariant.load !0
  %cond1 = icmp eq i8 %1, 1
  br i1 %cond1, label %if.else.i.i, label %lor.lhs.false.i.i

if.else.i.i:
  %2 = load i8, ptr %a2, !invariant.load !0
  %cond2 = icmp eq i8 %2, 2
  br i1 %cond2, label %lor.lhs.false.i.i, label %for.inc.i

lor.lhs.false.i.i:
  %3 = load i8, ptr %a3, !invariant.load !0
  %cond3 = icmp eq i8 %3, 3
  br i1 %cond3, label %for.inc.i, label %if.end28.i

for.inc.i:
  %i.inc = add nsw i64 %i, 1
  %cmp17.i = icmp ult i64 %i.inc, %count
  br i1 %cmp17.i, label %for.body.i, label %if.end28.i

if.end28.i:
  ret void
}

!0 = !{}