; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 3
; PR1135
; RUN: llc %s -o - | FileCheck %s
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-darwin10.3"
define void @test(ptr nocapture %array, i32 %r0) nounwind ssp noredzone {
; CHECK-LABEL: test:
; CHECK: ## %bb.0: ## %bb.nph
; CHECK-NEXT: movb $32, %al
; CHECK-NEXT: xorl %ecx, %ecx
; CHECK-NEXT: xorl %edx, %edx
; CHECK-NEXT: xorl %r8d, %r8d
; CHECK-NEXT: .p2align 4, 0x90
; CHECK-NEXT: LBB0_1: ## %bb
; CHECK-NEXT: ## =>This Inner Loop Header: Depth=1
; CHECK-NEXT: cmpb $4, %r8b
; CHECK-NEXT: movzbl %r8b, %r8d
; CHECK-NEXT: cmovgel %ecx, %r8d
; CHECK-NEXT: sete %r9b
; CHECK-NEXT: addb %r9b, %dl
; CHECK-NEXT: leal (,%rdx,4), %r9d
; CHECK-NEXT: addb %r8b, %r9b
; CHECK-NEXT: shlb $2, %r9b
; CHECK-NEXT: movzbl %r9b, %r9d
; CHECK-NEXT: movl %esi, (%rdi,%r9,4)
; CHECK-NEXT: movl %esi, 8(%rdi,%r9,4)
; CHECK-NEXT: movl %esi, 4(%rdi,%r9,4)
; CHECK-NEXT: movl %esi, 12(%rdi,%r9,4)
; CHECK-NEXT: incb %r8b
; CHECK-NEXT: decb %al
; CHECK-NEXT: jne LBB0_1
; CHECK-NEXT: ## %bb.2: ## %return
; CHECK-NEXT: retq
bb.nph:
br label %bb
bb: ; preds = %bb, %bb.nph
%j.010 = phi i8 [ 0, %bb.nph ], [ %14, %bb ] ; <i8> [#uses=1]
%k.19 = phi i8 [ 0, %bb.nph ], [ %.k.1, %bb ] ; <i8> [#uses=1]
%i0.08 = phi i8 [ 0, %bb.nph ], [ %15, %bb ] ; <i8> [#uses=3]
%0 = icmp slt i8 %i0.08, 4 ; <i1> [#uses=1]
%iftmp.0.0 = select i1 %0, i8 %i0.08, i8 0 ; <i8> [#uses=2]
%1 = icmp eq i8 %i0.08, 4 ; <i1> [#uses=1]
%2 = zext i1 %1 to i8 ; <i8> [#uses=1]
%.k.1 = add i8 %2, %k.19 ; <i8> [#uses=2]
%3 = shl i8 %.k.1, 2 ; <i8> [#uses=1]
%4 = add i8 %3, %iftmp.0.0 ; <i8> [#uses=1]
%5 = shl i8 %4, 2 ; <i8> [#uses=1]
%6 = zext i8 %5 to i64 ; <i64> [#uses=4]
%7 = getelementptr inbounds i32, ptr %array, i64 %6 ; <ptr> [#uses=1]
store i32 %r0, ptr %7, align 4
%8 = or i64 %6, 2 ; <i64> [#uses=1]
%9 = getelementptr inbounds i32, ptr %array, i64 %8 ; <ptr> [#uses=1]
store i32 %r0, ptr %9, align 4
%10 = or i64 %6, 1 ; <i64> [#uses=1]
%11 = getelementptr inbounds i32, ptr %array, i64 %10 ; <ptr> [#uses=1]
store i32 %r0, ptr %11, align 4
%12 = or i64 %6, 3 ; <i64> [#uses=1]
%13 = getelementptr inbounds i32, ptr %array, i64 %12 ; <ptr> [#uses=1]
store i32 %r0, ptr %13, align 4
%14 = add nsw i8 %j.010, 1 ; <i8> [#uses=2]
%15 = add i8 %iftmp.0.0, 1 ; <i8> [#uses=1]
%exitcond = icmp eq i8 %14, 32 ; <i1> [#uses=1]
br i1 %exitcond, label %return, label %bb
return: ; preds = %bb
ret void
}
define void @test1(ptr nocapture %array, i32 %r0, i8 signext %k, i8 signext %i0) nounwind {
; CHECK-LABEL: test1:
; CHECK: ## %bb.0: ## %bb.nph
; CHECK-NEXT: ## kill: def $ecx killed $ecx def $rcx
; CHECK-NEXT: movb $32, %al
; CHECK-NEXT: xorl %r8d, %r8d
; CHECK-NEXT: .p2align 4, 0x90
; CHECK-NEXT: LBB1_1: ## %for.body
; CHECK-NEXT: ## =>This Inner Loop Header: Depth=1
; CHECK-NEXT: cmpb $4, %cl
; CHECK-NEXT: movzbl %cl, %ecx
; CHECK-NEXT: cmovgel %r8d, %ecx
; CHECK-NEXT: sete %r9b
; CHECK-NEXT: addb %r9b, %dl
; CHECK-NEXT: leal (,%rcx,4), %r9d
; CHECK-NEXT: movl %edx, %r10d
; CHECK-NEXT: shlb $4, %r10b
; CHECK-NEXT: addb %r9b, %r10b
; CHECK-NEXT: movzbl %r10b, %r9d
; CHECK-NEXT: movl %esi, (%rdi,%r9,4)
; CHECK-NEXT: movl %esi, 8(%rdi,%r9,4)
; CHECK-NEXT: movl %esi, 4(%rdi,%r9,4)
; CHECK-NEXT: movl %esi, 12(%rdi,%r9,4)
; CHECK-NEXT: incb %cl
; CHECK-NEXT: decb %al
; CHECK-NEXT: jne LBB1_1
; CHECK-NEXT: ## %bb.2: ## %for.end
; CHECK-NEXT: retq
bb.nph:
br label %for.body
for.body: ; preds = %for.body, %bb.nph
%j.065 = phi i8 [ 0, %bb.nph ], [ %inc52, %for.body ] ; <i8> [#uses=1]
%i0.addr.064 = phi i8 [ %i0, %bb.nph ], [ %add, %for.body ] ; <i8> [#uses=3]
%k.addr.163 = phi i8 [ %k, %bb.nph ], [ %inc.k.addr.1, %for.body ] ; <i8> [#uses=1]
%cmp5 = icmp slt i8 %i0.addr.064, 4 ; <i1> [#uses=1]
%cond = select i1 %cmp5, i8 %i0.addr.064, i8 0 ; <i8> [#uses=2]
%cmp12 = icmp eq i8 %i0.addr.064, 4 ; <i1> [#uses=1]
%inc = zext i1 %cmp12 to i8 ; <i8> [#uses=1]
%inc.k.addr.1 = add i8 %inc, %k.addr.163 ; <i8> [#uses=2]
%mul = shl i8 %cond, 2 ; <i8> [#uses=1]
%mul22 = shl i8 %inc.k.addr.1, 4 ; <i8> [#uses=1]
%add23 = add i8 %mul22, %mul ; <i8> [#uses=1]
%idxprom = zext i8 %add23 to i64 ; <i64> [#uses=4]
%arrayidx = getelementptr inbounds i32, ptr %array, i64 %idxprom ; <ptr> [#uses=1]
store i32 %r0, ptr %arrayidx
%add3356 = or i64 %idxprom, 2 ; <i64> [#uses=1]
%arrayidx36 = getelementptr inbounds i32, ptr %array, i64 %add3356 ; <ptr> [#uses=1]
store i32 %r0, ptr %arrayidx36
%add4058 = or i64 %idxprom, 1 ; <i64> [#uses=1]
%arrayidx43 = getelementptr inbounds i32, ptr %array, i64 %add4058 ; <ptr> [#uses=1]
store i32 %r0, ptr %arrayidx43
%add4760 = or i64 %idxprom, 3 ; <i64> [#uses=1]
%arrayidx50 = getelementptr inbounds i32, ptr %array, i64 %add4760 ; <ptr> [#uses=1]
store i32 %r0, ptr %arrayidx50
%inc52 = add nsw i8 %j.065, 1 ; <i8> [#uses=2]
%add = add i8 %cond, 1 ; <i8> [#uses=1]
%exitcond = icmp eq i8 %inc52, 32 ; <i1> [#uses=1]
br i1 %exitcond, label %for.end, label %for.body
for.end: ; preds = %for.body
ret void
}