311 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc < %s -mtriple=i686-unknown | FileCheck %s --check-prefix=X863; RUN: llc < %s -mtriple=x86_64-unknown | FileCheck %s --check-prefix=X644 5; Test coverage for matchAddressRecursively's MUL handling6 7; Based off:8; struct A {9; int m_ints[5];10; int m_bar();11; };12; struct {13; A* m_data;14; } c;15; void foo(bool b, int i) {16; if (b)17; return;18; int j = c.m_data[i + 1].m_bar();19; foo(false, j);20; }21 22%struct.A = type { [5 x i32] }23 24define void @foo_sext_nsw(i1 zeroext, i32) nounwind {25; X86-LABEL: foo_sext_nsw:26; X86: # %bb.0:27; X86-NEXT: cmpb $0, {{[0-9]+}}(%esp)28; X86-NEXT: je .LBB0_129; X86-NEXT: # %bb.3:30; X86-NEXT: retl31; X86-NEXT: .LBB0_1: # %.preheader32; X86-NEXT: movl {{[0-9]+}}(%esp), %eax33; X86-NEXT: .p2align 434; X86-NEXT: .LBB0_2: # =>This Inner Loop Header: Depth=135; X86-NEXT: leal (%eax,%eax,4), %eax36; X86-NEXT: leal 20(,%eax,4), %eax37; X86-NEXT: pushl %eax38; X86-NEXT: calll bar@PLT39; X86-NEXT: addl $4, %esp40; X86-NEXT: jmp .LBB0_241;42; X64-LABEL: foo_sext_nsw:43; X64: # %bb.0:44; X64-NEXT: pushq %rax45; X64-NEXT: testl %edi, %edi46; X64-NEXT: je .LBB0_147; X64-NEXT: # %bb.3:48; X64-NEXT: popq %rax49; X64-NEXT: retq50; X64-NEXT: .LBB0_1: # %.preheader51; X64-NEXT: movl %esi, %eax52; X64-NEXT: .p2align 453; X64-NEXT: .LBB0_2: # =>This Inner Loop Header: Depth=154; X64-NEXT: cltq55; X64-NEXT: shlq $2, %rax56; X64-NEXT: leaq 20(%rax,%rax,4), %rdi57; X64-NEXT: callq bar@PLT58; X64-NEXT: jmp .LBB0_259 br i1 %0, label %9, label %360 61 %4 = phi i32 [ %8, %3 ], [ %1, %2 ]62 %5 = add nsw i32 %4, 163 %6 = sext i32 %5 to i6464 %7 = getelementptr inbounds %struct.A, ptr null, i64 %665 %8 = tail call i32 @bar(ptr %7)66 br label %367 68 ret void69}70 71define void @foo_sext_nuw(i1 zeroext, i32) nounwind {72; X86-LABEL: foo_sext_nuw:73; X86: # %bb.0:74; X86-NEXT: cmpb $0, {{[0-9]+}}(%esp)75; X86-NEXT: je .LBB1_176; X86-NEXT: # %bb.3:77; X86-NEXT: retl78; X86-NEXT: .LBB1_1: # %.preheader79; X86-NEXT: movl {{[0-9]+}}(%esp), %eax80; X86-NEXT: .p2align 481; X86-NEXT: .LBB1_2: # =>This Inner Loop Header: Depth=182; X86-NEXT: leal (%eax,%eax,4), %eax83; X86-NEXT: leal 20(,%eax,4), %eax84; X86-NEXT: pushl %eax85; X86-NEXT: calll bar@PLT86; X86-NEXT: addl $4, %esp87; X86-NEXT: jmp .LBB1_288;89; X64-LABEL: foo_sext_nuw:90; X64: # %bb.0:91; X64-NEXT: pushq %rax92; X64-NEXT: testl %edi, %edi93; X64-NEXT: je .LBB1_194; X64-NEXT: # %bb.3:95; X64-NEXT: popq %rax96; X64-NEXT: retq97; X64-NEXT: .LBB1_1: # %.preheader98; X64-NEXT: movl %esi, %eax99; X64-NEXT: .p2align 4100; X64-NEXT: .LBB1_2: # =>This Inner Loop Header: Depth=1101; X64-NEXT: incl %eax102; X64-NEXT: cltq103; X64-NEXT: shlq $2, %rax104; X64-NEXT: leaq (%rax,%rax,4), %rdi105; X64-NEXT: callq bar@PLT106; X64-NEXT: jmp .LBB1_2107 br i1 %0, label %9, label %3108 109 %4 = phi i32 [ %8, %3 ], [ %1, %2 ]110 %5 = add nuw i32 %4, 1111 %6 = sext i32 %5 to i64112 %7 = getelementptr inbounds %struct.A, ptr null, i64 %6113 %8 = tail call i32 @bar(ptr %7)114 br label %3115 116 ret void117}118 119define void @foo_zext_nsw(i1 zeroext, i32) nounwind {120; X86-LABEL: foo_zext_nsw:121; X86: # %bb.0:122; X86-NEXT: cmpb $0, {{[0-9]+}}(%esp)123; X86-NEXT: je .LBB2_1124; X86-NEXT: # %bb.3:125; X86-NEXT: retl126; X86-NEXT: .LBB2_1: # %.preheader127; X86-NEXT: movl {{[0-9]+}}(%esp), %eax128; X86-NEXT: .p2align 4129; X86-NEXT: .LBB2_2: # =>This Inner Loop Header: Depth=1130; X86-NEXT: leal (%eax,%eax,4), %eax131; X86-NEXT: leal 20(,%eax,4), %eax132; X86-NEXT: pushl %eax133; X86-NEXT: calll bar@PLT134; X86-NEXT: addl $4, %esp135; X86-NEXT: jmp .LBB2_2136;137; X64-LABEL: foo_zext_nsw:138; X64: # %bb.0:139; X64-NEXT: pushq %rax140; X64-NEXT: testl %edi, %edi141; X64-NEXT: je .LBB2_1142; X64-NEXT: # %bb.3:143; X64-NEXT: popq %rax144; X64-NEXT: retq145; X64-NEXT: .LBB2_1: # %.preheader146; X64-NEXT: movl %esi, %eax147; X64-NEXT: .p2align 4148; X64-NEXT: .LBB2_2: # =>This Inner Loop Header: Depth=1149; X64-NEXT: incl %eax150; X64-NEXT: shlq $2, %rax151; X64-NEXT: leaq (%rax,%rax,4), %rdi152; X64-NEXT: callq bar@PLT153; X64-NEXT: # kill: def $eax killed $eax def $rax154; X64-NEXT: jmp .LBB2_2155 br i1 %0, label %9, label %3156 157 %4 = phi i32 [ %8, %3 ], [ %1, %2 ]158 %5 = add nsw i32 %4, 1159 %6 = zext i32 %5 to i64160 %7 = getelementptr inbounds %struct.A, ptr null, i64 %6161 %8 = tail call i32 @bar(ptr %7)162 br label %3163 164 ret void165}166 167define void @foo_zext_nuw(i1 zeroext, i32) nounwind {168; X86-LABEL: foo_zext_nuw:169; X86: # %bb.0:170; X86-NEXT: cmpb $0, {{[0-9]+}}(%esp)171; X86-NEXT: je .LBB3_1172; X86-NEXT: # %bb.3:173; X86-NEXT: retl174; X86-NEXT: .LBB3_1: # %.preheader175; X86-NEXT: movl {{[0-9]+}}(%esp), %eax176; X86-NEXT: .p2align 4177; X86-NEXT: .LBB3_2: # =>This Inner Loop Header: Depth=1178; X86-NEXT: leal (%eax,%eax,4), %eax179; X86-NEXT: leal 20(,%eax,4), %eax180; X86-NEXT: pushl %eax181; X86-NEXT: calll bar@PLT182; X86-NEXT: addl $4, %esp183; X86-NEXT: jmp .LBB3_2184;185; X64-LABEL: foo_zext_nuw:186; X64: # %bb.0:187; X64-NEXT: pushq %rax188; X64-NEXT: testl %edi, %edi189; X64-NEXT: je .LBB3_1190; X64-NEXT: # %bb.3:191; X64-NEXT: popq %rax192; X64-NEXT: retq193; X64-NEXT: .LBB3_1: # %.preheader194; X64-NEXT: movl %esi, %eax195; X64-NEXT: .p2align 4196; X64-NEXT: .LBB3_2: # =>This Inner Loop Header: Depth=1197; X64-NEXT: movl %eax, %eax198; X64-NEXT: shlq $2, %rax199; X64-NEXT: leaq 20(%rax,%rax,4), %rdi200; X64-NEXT: callq bar@PLT201; X64-NEXT: jmp .LBB3_2202 br i1 %0, label %9, label %3203 204 %4 = phi i32 [ %8, %3 ], [ %1, %2 ]205 %5 = add nuw i32 %4, 1206 %6 = zext i32 %5 to i64207 %7 = getelementptr inbounds %struct.A, ptr null, i64 %6208 %8 = tail call i32 @bar(ptr %7)209 br label %3210 211 ret void212}213 214define void @foo_sext(i1 zeroext, i32) nounwind {215; X86-LABEL: foo_sext:216; X86: # %bb.0:217; X86-NEXT: cmpb $0, {{[0-9]+}}(%esp)218; X86-NEXT: je .LBB4_1219; X86-NEXT: # %bb.3:220; X86-NEXT: retl221; X86-NEXT: .LBB4_1: # %.preheader222; X86-NEXT: movl {{[0-9]+}}(%esp), %eax223; X86-NEXT: .p2align 4224; X86-NEXT: .LBB4_2: # =>This Inner Loop Header: Depth=1225; X86-NEXT: leal (%eax,%eax,4), %eax226; X86-NEXT: leal 20(,%eax,4), %eax227; X86-NEXT: pushl %eax228; X86-NEXT: calll bar@PLT229; X86-NEXT: addl $4, %esp230; X86-NEXT: jmp .LBB4_2231;232; X64-LABEL: foo_sext:233; X64: # %bb.0:234; X64-NEXT: pushq %rax235; X64-NEXT: testl %edi, %edi236; X64-NEXT: je .LBB4_1237; X64-NEXT: # %bb.3:238; X64-NEXT: popq %rax239; X64-NEXT: retq240; X64-NEXT: .LBB4_1: # %.preheader241; X64-NEXT: movl %esi, %eax242; X64-NEXT: .p2align 4243; X64-NEXT: .LBB4_2: # =>This Inner Loop Header: Depth=1244; X64-NEXT: incl %eax245; X64-NEXT: cltq246; X64-NEXT: shlq $2, %rax247; X64-NEXT: leaq (%rax,%rax,4), %rdi248; X64-NEXT: callq bar@PLT249; X64-NEXT: jmp .LBB4_2250 br i1 %0, label %9, label %3251 252 %4 = phi i32 [ %8, %3 ], [ %1, %2 ]253 %5 = add i32 %4, 1254 %6 = sext i32 %5 to i64255 %7 = getelementptr inbounds %struct.A, ptr null, i64 %6256 %8 = tail call i32 @bar(ptr %7)257 br label %3258 259 ret void260}261 262define void @foo_zext(i1 zeroext, i32) nounwind {263; X86-LABEL: foo_zext:264; X86: # %bb.0:265; X86-NEXT: cmpb $0, {{[0-9]+}}(%esp)266; X86-NEXT: je .LBB5_1267; X86-NEXT: # %bb.3:268; X86-NEXT: retl269; X86-NEXT: .LBB5_1: # %.preheader270; X86-NEXT: movl {{[0-9]+}}(%esp), %eax271; X86-NEXT: .p2align 4272; X86-NEXT: .LBB5_2: # =>This Inner Loop Header: Depth=1273; X86-NEXT: leal (%eax,%eax,4), %eax274; X86-NEXT: leal 20(,%eax,4), %eax275; X86-NEXT: pushl %eax276; X86-NEXT: calll bar@PLT277; X86-NEXT: addl $4, %esp278; X86-NEXT: jmp .LBB5_2279;280; X64-LABEL: foo_zext:281; X64: # %bb.0:282; X64-NEXT: pushq %rax283; X64-NEXT: testl %edi, %edi284; X64-NEXT: je .LBB5_1285; X64-NEXT: # %bb.3:286; X64-NEXT: popq %rax287; X64-NEXT: retq288; X64-NEXT: .LBB5_1: # %.preheader289; X64-NEXT: movl %esi, %eax290; X64-NEXT: .p2align 4291; X64-NEXT: .LBB5_2: # =>This Inner Loop Header: Depth=1292; X64-NEXT: incl %eax293; X64-NEXT: shlq $2, %rax294; X64-NEXT: leaq (%rax,%rax,4), %rdi295; X64-NEXT: callq bar@PLT296; X64-NEXT: # kill: def $eax killed $eax def $rax297; X64-NEXT: jmp .LBB5_2298 br i1 %0, label %9, label %3299 300 %4 = phi i32 [ %8, %3 ], [ %1, %2 ]301 %5 = add i32 %4, 1302 %6 = zext i32 %5 to i64303 %7 = getelementptr inbounds %struct.A, ptr null, i64 %6304 %8 = tail call i32 @bar(ptr %7)305 br label %3306 307 ret void308}309 310declare i32 @bar(ptr)311