brintos

brintos / llvm-project-archived public Read only

0
0
Text · 19.2 KiB · 082b876 Raw
565 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc < %s -O3 -mtriple=x86_64-unknown-unknown -mcpu=core2 | FileCheck %s -check-prefix=X643; RUN: llc < %s -O3 -mtriple=i686-unknown-unknown   -mcpu=core2 | FileCheck %s -check-prefix=X324 5; @simple is the most basic chain of address induction variables. Chaining6; saves at least one register and avoids complex addressing and setup7; code.8;9; %x * 410; no other address computation in the preheader11; no complex address modes12;13; no expensive address computation in the preheader14; no complex address modes15 16define i32 @simple(ptr %a, ptr %b, i32 %x) nounwind {17; X64-LABEL: simple:18; X64:       # %bb.0: # %entry19; X64-NEXT:    movslq %edx, %rcx20; X64-NEXT:    shlq $2, %rcx21; X64-NEXT:    xorl %eax, %eax22; X64-NEXT:    leaq (%rcx,%rcx), %rdx23; X64-NEXT:    .p2align 424; X64-NEXT:  .LBB0_1: # %loop25; X64-NEXT:    # =>This Inner Loop Header: Depth=126; X64-NEXT:    addl (%rdi), %eax27; X64-NEXT:    addl (%rdi,%rcx), %eax28; X64-NEXT:    addq %rcx, %rdi29; X64-NEXT:    addl (%rcx,%rdi), %eax30; X64-NEXT:    addq %rcx, %rdi31; X64-NEXT:    addl (%rcx,%rdi), %eax32; X64-NEXT:    addq %rdx, %rdi33; X64-NEXT:    cmpq %rsi, %rdi34; X64-NEXT:    jne .LBB0_135; X64-NEXT:  # %bb.2: # %exit36; X64-NEXT:    retq37;38; X32-LABEL: simple:39; X32:       # %bb.0: # %entry40; X32-NEXT:    pushl %edi41; X32-NEXT:    pushl %esi42; X32-NEXT:    movl {{[0-9]+}}(%esp), %ecx43; X32-NEXT:    movl {{[0-9]+}}(%esp), %edi44; X32-NEXT:    movl {{[0-9]+}}(%esp), %edx45; X32-NEXT:    shll $2, %edx46; X32-NEXT:    xorl %eax, %eax47; X32-NEXT:    leal (%edx,%edx), %esi48; X32-NEXT:    .p2align 449; X32-NEXT:  .LBB0_1: # %loop50; X32-NEXT:    # =>This Inner Loop Header: Depth=151; X32-NEXT:    addl (%edi), %eax52; X32-NEXT:    addl (%edi,%edx), %eax53; X32-NEXT:    addl %edx, %edi54; X32-NEXT:    addl (%edx,%edi), %eax55; X32-NEXT:    addl %edx, %edi56; X32-NEXT:    addl (%edx,%edi), %eax57; X32-NEXT:    addl %esi, %edi58; X32-NEXT:    cmpl %ecx, %edi59; X32-NEXT:    jne .LBB0_160; X32-NEXT:  # %bb.2: # %exit61; X32-NEXT:    popl %esi62; X32-NEXT:    popl %edi63; X32-NEXT:    retl64entry:65  br label %loop66loop:67  %iv = phi ptr [ %a, %entry ], [ %iv4, %loop ]68  %s = phi i32 [ 0, %entry ], [ %s4, %loop ]69  %v = load i32, ptr %iv70  %iv1 = getelementptr inbounds i32, ptr %iv, i32 %x71  %v1 = load i32, ptr %iv172  %iv2 = getelementptr inbounds i32, ptr %iv1, i32 %x73  %v2 = load i32, ptr %iv274  %iv3 = getelementptr inbounds i32, ptr %iv2, i32 %x75  %v3 = load i32, ptr %iv376  %s1 = add i32 %s, %v77  %s2 = add i32 %s1, %v178  %s3 = add i32 %s2, %v279  %s4 = add i32 %s3, %v380  %iv4 = getelementptr inbounds i32, ptr %iv3, i32 %x81  %cmp = icmp eq ptr %iv4, %b82  br i1 %cmp, label %exit, label %loop83exit:84  ret i32 %s485}86 87; @user is not currently chained because the IV is live across memory ops.88;89; expensive address computation in the preheader90; complex address modes91define i32 @user(ptr %a, ptr %b, i32 %x) nounwind {92; X64-LABEL: user:93; X64:       # %bb.0: # %entry94; X64-NEXT:    movslq %edx, %rcx95; X64-NEXT:    movq %rcx, %rdx96; X64-NEXT:    shlq $4, %rdx97; X64-NEXT:    leaq (,%rcx,4), %rax98; X64-NEXT:    leaq (%rax,%rax,2), %r899; X64-NEXT:    xorl %eax, %eax100; X64-NEXT:    .p2align 4101; X64-NEXT:  .LBB1_1: # %loop102; X64-NEXT:    # =>This Inner Loop Header: Depth=1103; X64-NEXT:    addl (%rdi), %eax104; X64-NEXT:    addl (%rdi,%rcx,4), %eax105; X64-NEXT:    addl (%rdi,%rcx,8), %eax106; X64-NEXT:    addl (%rdi,%r8), %eax107; X64-NEXT:    movl %eax, (%rdi)108; X64-NEXT:    addq %rdx, %rdi109; X64-NEXT:    cmpq %rsi, %rdi110; X64-NEXT:    jne .LBB1_1111; X64-NEXT:  # %bb.2: # %exit112; X64-NEXT:    retq113;114; X32-LABEL: user:115; X32:       # %bb.0: # %entry116; X32-NEXT:    pushl %ebx117; X32-NEXT:    pushl %edi118; X32-NEXT:    pushl %esi119; X32-NEXT:    movl {{[0-9]+}}(%esp), %ecx120; X32-NEXT:    movl {{[0-9]+}}(%esp), %edx121; X32-NEXT:    movl {{[0-9]+}}(%esp), %esi122; X32-NEXT:    movl %ecx, %edi123; X32-NEXT:    shll $4, %edi124; X32-NEXT:    leal (,%ecx,4), %eax125; X32-NEXT:    leal (%eax,%eax,2), %ebx126; X32-NEXT:    xorl %eax, %eax127; X32-NEXT:    .p2align 4128; X32-NEXT:  .LBB1_1: # %loop129; X32-NEXT:    # =>This Inner Loop Header: Depth=1130; X32-NEXT:    addl (%esi), %eax131; X32-NEXT:    addl (%esi,%ecx,4), %eax132; X32-NEXT:    addl (%esi,%ecx,8), %eax133; X32-NEXT:    addl (%esi,%ebx), %eax134; X32-NEXT:    movl %eax, (%esi)135; X32-NEXT:    addl %edi, %esi136; X32-NEXT:    cmpl %edx, %esi137; X32-NEXT:    jne .LBB1_1138; X32-NEXT:  # %bb.2: # %exit139; X32-NEXT:    popl %esi140; X32-NEXT:    popl %edi141; X32-NEXT:    popl %ebx142; X32-NEXT:    retl143entry:144  br label %loop145loop:146  %iv = phi ptr [ %a, %entry ], [ %iv4, %loop ]147  %s = phi i32 [ 0, %entry ], [ %s4, %loop ]148  %v = load i32, ptr %iv149  %iv1 = getelementptr inbounds i32, ptr %iv, i32 %x150  %v1 = load i32, ptr %iv1151  %iv2 = getelementptr inbounds i32, ptr %iv1, i32 %x152  %v2 = load i32, ptr %iv2153  %iv3 = getelementptr inbounds i32, ptr %iv2, i32 %x154  %v3 = load i32, ptr %iv3155  %s1 = add i32 %s, %v156  %s2 = add i32 %s1, %v1157  %s3 = add i32 %s2, %v2158  %s4 = add i32 %s3, %v3159  %iv4 = getelementptr inbounds i32, ptr %iv3, i32 %x160  store i32 %s4, ptr %iv161  %cmp = icmp eq ptr %iv4, %b162  br i1 %cmp, label %exit, label %loop163exit:164  ret i32 %s4165}166 167; @extrastride is a slightly more interesting case of a single168; complete chain with multiple strides. The test case IR is what LSR169; used to do, and exactly what we don't want to do. LSR's new IV170; chaining feature should now undo the damage.171;172; We currently don't handle this on X64 because the sexts cause173; strange increment expressions like this:174; IV + ((sext i32 (2 * %s) to i64) + (-1 * (sext i32 %s to i64)))175;176; For x32, no spills in the preheader, no complex address modes, no reloads.177 178define void @extrastride(ptr nocapture %main, i32 %main_stride, ptr nocapture %res, i32 %x, i32 %y, i32 %z) nounwind {179; X64-LABEL: extrastride:180; X64:       # %bb.0: # %entry181; X64-NEXT:    # kill: def $ecx killed $ecx def $rcx182; X64-NEXT:    # kill: def $esi killed $esi def $rsi183; X64-NEXT:    testl %r9d, %r9d184; X64-NEXT:    je .LBB2_4185; X64-NEXT:  # %bb.1: # %for.body.lr.ph186; X64-NEXT:    pushq %rbx187; X64-NEXT:    leal (%rsi,%rsi), %r10d188; X64-NEXT:    leal (%rsi,%rsi,2), %r11d189; X64-NEXT:    addl %esi, %ecx190; X64-NEXT:    leal (,%rsi,4), %eax191; X64-NEXT:    leal (%rcx,%rsi,4), %ebx192; X64-NEXT:    cltq193; X64-NEXT:    movslq %r11d, %rcx194; X64-NEXT:    movslq %r10d, %r10195; X64-NEXT:    movslq %esi, %rsi196; X64-NEXT:    movslq %r8d, %r8197; X64-NEXT:    shlq $2, %r8198; X64-NEXT:    movslq %ebx, %r11199; X64-NEXT:    .p2align 4200; X64-NEXT:  .LBB2_2: # %for.body201; X64-NEXT:    # =>This Inner Loop Header: Depth=1202; X64-NEXT:    movl (%rdi,%rsi), %ebx203; X64-NEXT:    addl (%rdi), %ebx204; X64-NEXT:    addl (%rdi,%r10), %ebx205; X64-NEXT:    addl (%rdi,%rcx), %ebx206; X64-NEXT:    addl (%rdi,%rax), %ebx207; X64-NEXT:    movl %ebx, (%rdx)208; X64-NEXT:    addq %r11, %rdi209; X64-NEXT:    addq %r8, %rdx210; X64-NEXT:    decl %r9d211; X64-NEXT:    jne .LBB2_2212; X64-NEXT:  # %bb.3:213; X64-NEXT:    popq %rbx214; X64-NEXT:  .LBB2_4: # %for.end215; X64-NEXT:    retq216;217; X32-LABEL: extrastride:218; X32:       # %bb.0: # %entry219; X32-NEXT:    pushl %ebp220; X32-NEXT:    pushl %ebx221; X32-NEXT:    pushl %edi222; X32-NEXT:    pushl %esi223; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax224; X32-NEXT:    testl %eax, %eax225; X32-NEXT:    je .LBB2_3226; X32-NEXT:  # %bb.1: # %for.body.lr.ph227; X32-NEXT:    movl {{[0-9]+}}(%esp), %ecx228; X32-NEXT:    movl {{[0-9]+}}(%esp), %edx229; X32-NEXT:    movl {{[0-9]+}}(%esp), %esi230; X32-NEXT:    movl {{[0-9]+}}(%esp), %ebx231; X32-NEXT:    movl {{[0-9]+}}(%esp), %edi232; X32-NEXT:    addl %esi, %edi233; X32-NEXT:    shll $2, %ecx234; X32-NEXT:    .p2align 4235; X32-NEXT:  .LBB2_2: # %for.body236; X32-NEXT:    # =>This Inner Loop Header: Depth=1237; X32-NEXT:    movl %ebx, %ebp238; X32-NEXT:    movl (%ebx,%esi), %ebx239; X32-NEXT:    addl (%ebp), %ebx240; X32-NEXT:    addl %esi, %ebp241; X32-NEXT:    addl (%esi,%ebp), %ebx242; X32-NEXT:    addl %esi, %ebp243; X32-NEXT:    addl (%esi,%ebp), %ebx244; X32-NEXT:    addl %esi, %ebp245; X32-NEXT:    addl (%esi,%ebp), %ebx246; X32-NEXT:    movl %ebx, (%edx)247; X32-NEXT:    leal (%ebp,%esi), %ebx248; X32-NEXT:    addl %edi, %ebx249; X32-NEXT:    addl %ecx, %edx250; X32-NEXT:    decl %eax251; X32-NEXT:    jne .LBB2_2252; X32-NEXT:  .LBB2_3: # %for.end253; X32-NEXT:    popl %esi254; X32-NEXT:    popl %edi255; X32-NEXT:    popl %ebx256; X32-NEXT:    popl %ebp257; X32-NEXT:    retl258entry:259  %cmp8 = icmp eq i32 %z, 0260  br i1 %cmp8, label %for.end, label %for.body.lr.ph261 262for.body.lr.ph:                                   ; preds = %entry263  %add.ptr.sum = shl i32 %main_stride, 1 ; s*2264  %add.ptr1.sum = add i32 %add.ptr.sum, %main_stride ; s*3265  %add.ptr2.sum = add i32 %x, %main_stride ; s + x266  %add.ptr4.sum = shl i32 %main_stride, 2 ; s*4267  %add.ptr3.sum = add i32 %add.ptr2.sum, %add.ptr4.sum ; total IV stride = s*5+x268  br label %for.body269 270for.body:                                         ; preds = %for.body.lr.ph, %for.body271  %main.addr.011 = phi ptr [ %main, %for.body.lr.ph ], [ %add.ptr6, %for.body ]272  %i.010 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]273  %res.addr.09 = phi ptr [ %res, %for.body.lr.ph ], [ %add.ptr7, %for.body ]274  %0 = load i32, ptr %main.addr.011, align 4275  %add.ptr = getelementptr inbounds i8, ptr %main.addr.011, i32 %main_stride276  %1 = load i32, ptr %add.ptr, align 4277  %add.ptr1 = getelementptr inbounds i8, ptr %main.addr.011, i32 %add.ptr.sum278  %2 = load i32, ptr %add.ptr1, align 4279  %add.ptr2 = getelementptr inbounds i8, ptr %main.addr.011, i32 %add.ptr1.sum280  %3 = load i32, ptr %add.ptr2, align 4281  %add.ptr3 = getelementptr inbounds i8, ptr %main.addr.011, i32 %add.ptr4.sum282  %4 = load i32, ptr %add.ptr3, align 4283  %add = add i32 %1, %0284  %add4 = add i32 %add, %2285  %add5 = add i32 %add4, %3286  %add6 = add i32 %add5, %4287  store i32 %add6, ptr %res.addr.09, align 4288  %add.ptr6 = getelementptr inbounds i8, ptr %main.addr.011, i32 %add.ptr3.sum289  %add.ptr7 = getelementptr inbounds i32, ptr %res.addr.09, i32 %y290  %inc = add i32 %i.010, 1291  %cmp = icmp eq i32 %inc, %z292  br i1 %cmp, label %for.end, label %for.body293 294for.end:                                          ; preds = %for.body, %entry295  ret void296}297 298; @foldedidx is an unrolled variant of this loop:299;  for (unsigned long i = 0; i < len; i += s) {300;    c[i] = a[i] + b[i];301;  }302; where 's' can be folded into the addressing mode.303; Consequently, we should *not* form any chains.304 305define void @foldedidx(ptr nocapture %a, ptr nocapture %b, ptr nocapture %c) nounwind ssp {306; X64-LABEL: foldedidx:307; X64:       # %bb.0: # %entry308; X64-NEXT:    movl $3, %eax309; X64-NEXT:    .p2align 4310; X64-NEXT:  .LBB3_1: # %for.body311; X64-NEXT:    # =>This Inner Loop Header: Depth=1312; X64-NEXT:    movzbl -3(%rdi,%rax), %ecx313; X64-NEXT:    movzbl -3(%rsi,%rax), %r8d314; X64-NEXT:    addl %ecx, %r8d315; X64-NEXT:    movb %r8b, -3(%rdx,%rax)316; X64-NEXT:    movzbl -2(%rdi,%rax), %ecx317; X64-NEXT:    movzbl -2(%rsi,%rax), %r8d318; X64-NEXT:    addl %ecx, %r8d319; X64-NEXT:    movb %r8b, -2(%rdx,%rax)320; X64-NEXT:    movzbl -1(%rdi,%rax), %ecx321; X64-NEXT:    movzbl -1(%rsi,%rax), %r8d322; X64-NEXT:    addl %ecx, %r8d323; X64-NEXT:    movb %r8b, -1(%rdx,%rax)324; X64-NEXT:    movzbl (%rdi,%rax), %ecx325; X64-NEXT:    movzbl (%rsi,%rax), %r8d326; X64-NEXT:    addl %ecx, %r8d327; X64-NEXT:    movb %r8b, (%rdx,%rax)328; X64-NEXT:    addq $4, %rax329; X64-NEXT:    cmpl $403, %eax # imm = 0x193330; X64-NEXT:    jne .LBB3_1331; X64-NEXT:  # %bb.2: # %for.end332; X64-NEXT:    retq333;334; X32-LABEL: foldedidx:335; X32:       # %bb.0: # %entry336; X32-NEXT:    pushl %ebx337; X32-NEXT:    pushl %edi338; X32-NEXT:    pushl %esi339; X32-NEXT:    movl $3, %eax340; X32-NEXT:    movl {{[0-9]+}}(%esp), %ecx341; X32-NEXT:    movl {{[0-9]+}}(%esp), %edx342; X32-NEXT:    movl {{[0-9]+}}(%esp), %esi343; X32-NEXT:    .p2align 4344; X32-NEXT:  .LBB3_1: # %for.body345; X32-NEXT:    # =>This Inner Loop Header: Depth=1346; X32-NEXT:    movzbl -3(%esi,%eax), %edi347; X32-NEXT:    movzbl -3(%edx,%eax), %ebx348; X32-NEXT:    addl %edi, %ebx349; X32-NEXT:    movb %bl, -3(%ecx,%eax)350; X32-NEXT:    movzbl -2(%esi,%eax), %edi351; X32-NEXT:    movzbl -2(%edx,%eax), %ebx352; X32-NEXT:    addl %edi, %ebx353; X32-NEXT:    movb %bl, -2(%ecx,%eax)354; X32-NEXT:    movzbl -1(%esi,%eax), %edi355; X32-NEXT:    movzbl -1(%edx,%eax), %ebx356; X32-NEXT:    addl %edi, %ebx357; X32-NEXT:    movb %bl, -1(%ecx,%eax)358; X32-NEXT:    movzbl (%esi,%eax), %edi359; X32-NEXT:    movzbl (%edx,%eax), %ebx360; X32-NEXT:    addl %edi, %ebx361; X32-NEXT:    movb %bl, (%ecx,%eax)362; X32-NEXT:    addl $4, %eax363; X32-NEXT:    cmpl $403, %eax # imm = 0x193364; X32-NEXT:    jne .LBB3_1365; X32-NEXT:  # %bb.2: # %for.end366; X32-NEXT:    popl %esi367; X32-NEXT:    popl %edi368; X32-NEXT:    popl %ebx369; X32-NEXT:    retl370entry:371  br label %for.body372 373for.body:                                         ; preds = %for.body, %entry374  %i.07 = phi i32 [ 0, %entry ], [ %inc.3, %for.body ]375  %arrayidx = getelementptr inbounds i8, ptr %a, i32 %i.07376  %0 = load i8, ptr %arrayidx, align 1377  %conv5 = zext i8 %0 to i32378  %arrayidx1 = getelementptr inbounds i8, ptr %b, i32 %i.07379  %1 = load i8, ptr %arrayidx1, align 1380  %conv26 = zext i8 %1 to i32381  %add = add nsw i32 %conv26, %conv5382  %conv3 = trunc i32 %add to i8383  %arrayidx4 = getelementptr inbounds i8, ptr %c, i32 %i.07384  store i8 %conv3, ptr %arrayidx4, align 1385  %inc1 = or disjoint i32 %i.07, 1386  %arrayidx.1 = getelementptr inbounds i8, ptr %a, i32 %inc1387  %2 = load i8, ptr %arrayidx.1, align 1388  %conv5.1 = zext i8 %2 to i32389  %arrayidx1.1 = getelementptr inbounds i8, ptr %b, i32 %inc1390  %3 = load i8, ptr %arrayidx1.1, align 1391  %conv26.1 = zext i8 %3 to i32392  %add.1 = add nsw i32 %conv26.1, %conv5.1393  %conv3.1 = trunc i32 %add.1 to i8394  %arrayidx4.1 = getelementptr inbounds i8, ptr %c, i32 %inc1395  store i8 %conv3.1, ptr %arrayidx4.1, align 1396  %inc.12 = or disjoint i32 %i.07, 2397  %arrayidx.2 = getelementptr inbounds i8, ptr %a, i32 %inc.12398  %4 = load i8, ptr %arrayidx.2, align 1399  %conv5.2 = zext i8 %4 to i32400  %arrayidx1.2 = getelementptr inbounds i8, ptr %b, i32 %inc.12401  %5 = load i8, ptr %arrayidx1.2, align 1402  %conv26.2 = zext i8 %5 to i32403  %add.2 = add nsw i32 %conv26.2, %conv5.2404  %conv3.2 = trunc i32 %add.2 to i8405  %arrayidx4.2 = getelementptr inbounds i8, ptr %c, i32 %inc.12406  store i8 %conv3.2, ptr %arrayidx4.2, align 1407  %inc.23 = or disjoint i32 %i.07, 3408  %arrayidx.3 = getelementptr inbounds i8, ptr %a, i32 %inc.23409  %6 = load i8, ptr %arrayidx.3, align 1410  %conv5.3 = zext i8 %6 to i32411  %arrayidx1.3 = getelementptr inbounds i8, ptr %b, i32 %inc.23412  %7 = load i8, ptr %arrayidx1.3, align 1413  %conv26.3 = zext i8 %7 to i32414  %add.3 = add nsw i32 %conv26.3, %conv5.3415  %conv3.3 = trunc i32 %add.3 to i8416  %arrayidx4.3 = getelementptr inbounds i8, ptr %c, i32 %inc.23417  store i8 %conv3.3, ptr %arrayidx4.3, align 1418  %inc.3 = add nsw i32 %i.07, 4419  %exitcond.3 = icmp eq i32 %inc.3, 400420  br i1 %exitcond.3, label %for.end, label %for.body421 422for.end:                                          ; preds = %for.body423  ret void424}425 426; @multioper tests instructions with multiple IV user operands. We427; should be able to chain them independent of each other.428 429define void @multioper(ptr %a, i32 %n) nounwind {430; X64-LABEL: multioper:431; X64:       # %bb.0: # %entry432; X64-NEXT:    xorl %eax, %eax433; X64-NEXT:    .p2align 4434; X64-NEXT:  .LBB4_1: # %for.body435; X64-NEXT:    # =>This Inner Loop Header: Depth=1436; X64-NEXT:    movl %eax, (%rdi,%rax,4)437; X64-NEXT:    leal 1(%rax), %ecx438; X64-NEXT:    movl %ecx, 4(%rdi,%rax,4)439; X64-NEXT:    leal 2(%rax), %ecx440; X64-NEXT:    movl %ecx, 8(%rdi,%rax,4)441; X64-NEXT:    leal 3(%rax), %ecx442; X64-NEXT:    movl %ecx, 12(%rdi,%rax,4)443; X64-NEXT:    addq $4, %rax444; X64-NEXT:    cmpl %esi, %eax445; X64-NEXT:    jl .LBB4_1446; X64-NEXT:  # %bb.2: # %exit447; X64-NEXT:    retq448;449; X32-LABEL: multioper:450; X32:       # %bb.0: # %entry451; X32-NEXT:    pushl %esi452; X32-NEXT:    xorl %eax, %eax453; X32-NEXT:    movl {{[0-9]+}}(%esp), %ecx454; X32-NEXT:    movl {{[0-9]+}}(%esp), %edx455; X32-NEXT:    .p2align 4456; X32-NEXT:  .LBB4_1: # %for.body457; X32-NEXT:    # =>This Inner Loop Header: Depth=1458; X32-NEXT:    movl %eax, (%edx,%eax,4)459; X32-NEXT:    leal 1(%eax), %esi460; X32-NEXT:    movl %esi, 4(%edx,%eax,4)461; X32-NEXT:    leal 2(%eax), %esi462; X32-NEXT:    movl %esi, 8(%edx,%eax,4)463; X32-NEXT:    leal 3(%eax), %esi464; X32-NEXT:    movl %esi, 12(%edx,%eax,4)465; X32-NEXT:    addl $4, %eax466; X32-NEXT:    cmpl %ecx, %eax467; X32-NEXT:    jl .LBB4_1468; X32-NEXT:  # %bb.2: # %exit469; X32-NEXT:    popl %esi470; X32-NEXT:    retl471entry:472  br label %for.body473 474for.body:475  %p = phi ptr [ %p.next, %for.body ], [ %a, %entry ]476  %i = phi i32 [ %inc4, %for.body ], [ 0, %entry ]477  store i32 %i, ptr %p, align 4478  %inc1 = or disjoint i32 %i, 1479  %add.ptr.i1 = getelementptr inbounds i32, ptr %p, i32 1480  store i32 %inc1, ptr %add.ptr.i1, align 4481  %inc2 = add nsw i32 %i, 2482  %add.ptr.i2 = getelementptr inbounds i32, ptr %p, i32 2483  store i32 %inc2, ptr %add.ptr.i2, align 4484  %inc3 = add nsw i32 %i, 3485  %add.ptr.i3 = getelementptr inbounds i32, ptr %p, i32 3486  store i32 %inc3, ptr %add.ptr.i3, align 4487  %p.next = getelementptr inbounds i32, ptr %p, i32 4488  %inc4 = add nsw i32 %i, 4489  %cmp = icmp slt i32 %inc4, %n490  br i1 %cmp, label %for.body, label %exit491 492exit:493  ret void494}495 496; @testCmpZero has a ICmpZero LSR use that should not be hidden from497; LSR. Profitable chains should have more than one nonzero increment498; anyway.499 500define void @testCmpZero(ptr %src, ptr %dst, i32 %srcidx, i32 %dstidx, i32 %len) nounwind ssp {501; X64-LABEL: testCmpZero:502; X64:       # %bb.0: # %entry503; X64-NEXT:    movslq %edx, %rdx504; X64-NEXT:    addq %rdx, %rdi505; X64-NEXT:    movslq %ecx, %rax506; X64-NEXT:    addq %rsi, %rax507; X64-NEXT:    addl %edx, %r8d508; X64-NEXT:    movslq %r8d, %rcx509; X64-NEXT:    subq %rdx, %rcx510; X64-NEXT:    xorl %edx, %edx511; X64-NEXT:    .p2align 4512; X64-NEXT:  .LBB5_1: # %for.body82.us513; X64-NEXT:    # =>This Inner Loop Header: Depth=1514; X64-NEXT:    movzbl (%rax,%rdx,4), %esi515; X64-NEXT:    movb %sil, (%rdi,%rdx)516; X64-NEXT:    incq %rdx517; X64-NEXT:    cmpq %rdx, %rcx518; X64-NEXT:    jne .LBB5_1519; X64-NEXT:  # %bb.2: # %return520; X64-NEXT:    retq521;522; X32-LABEL: testCmpZero:523; X32:       # %bb.0: # %entry524; X32-NEXT:    pushl %ebx525; X32-NEXT:    pushl %esi526; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax527; X32-NEXT:    movl {{[0-9]+}}(%esp), %ecx528; X32-NEXT:    addl {{[0-9]+}}(%esp), %ecx529; X32-NEXT:    movl {{[0-9]+}}(%esp), %edx530; X32-NEXT:    addl {{[0-9]+}}(%esp), %edx531; X32-NEXT:    xorl %esi, %esi532; X32-NEXT:    .p2align 4533; X32-NEXT:  .LBB5_1: # %for.body82.us534; X32-NEXT:    # =>This Inner Loop Header: Depth=1535; X32-NEXT:    movzbl (%edx,%esi,4), %ebx536; X32-NEXT:    movb %bl, (%ecx,%esi)537; X32-NEXT:    incl %esi538; X32-NEXT:    cmpl %esi, %eax539; X32-NEXT:    jne .LBB5_1540; X32-NEXT:  # %bb.2: # %return541; X32-NEXT:    popl %esi542; X32-NEXT:    popl %ebx543; X32-NEXT:    retl544entry:545  %dest0 = getelementptr inbounds i8, ptr %src, i32 %srcidx546  %source0 = getelementptr inbounds i8, ptr %dst, i32 %dstidx547  %add.ptr79.us.sum = add i32 %srcidx, %len548  %lftr.limit = getelementptr i8, ptr %src, i32 %add.ptr79.us.sum549  br label %for.body82.us550 551for.body82.us:552  %dest = phi ptr [ %dest0, %entry ], [ %incdec.ptr91.us, %for.body82.us ]553  %source = phi ptr [ %source0, %entry ], [ %add.ptr83.us, %for.body82.us ]554  %0 = load i32, ptr %source, align 4555  %trunc = trunc i32 %0 to i8556  %add.ptr83.us = getelementptr inbounds i8, ptr %source, i32 4557  %incdec.ptr91.us = getelementptr inbounds i8, ptr %dest, i32 1558  store i8 %trunc, ptr %dest, align 1559  %exitcond = icmp eq ptr %incdec.ptr91.us, %lftr.limit560  br i1 %exitcond, label %return, label %for.body82.us561 562return:563  ret void564}565