brintos

brintos / llvm-project-archived public Read only

0
0
Text · 14.4 KiB · cc46f04 Raw
476 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+slow-lea,+slow-3ops-lea,+sse,+sse2   | FileCheck %s --check-prefixes=ALL,X323; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+slow-lea,+slow-3ops-lea,+sse,+sse2 | FileCheck %s --check-prefixes=ALL,X644 5; Scalar tests. Trying to avoid LEA here, so the output is actually readable..6 7; add (add %x, C), %y8; Outer 'add' is commutative - 2 variants.9 10define i32 @sink_add_of_const_to_add0(i32 %a, i32 %b) {11; X32-LABEL: sink_add_of_const_to_add0:12; X32:       # %bb.0:13; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax14; X32-NEXT:    movl {{[0-9]+}}(%esp), %ecx15; X32-NEXT:    addl %ecx, %eax16; X32-NEXT:    addl $32, %eax17; X32-NEXT:    retl18;19; X64-LABEL: sink_add_of_const_to_add0:20; X64:       # %bb.0:21; X64-NEXT:    # kill: def $esi killed $esi def $rsi22; X64-NEXT:    # kill: def $edi killed $edi def $rdi23; X64-NEXT:    leal 32(%rdi,%rsi), %eax24; X64-NEXT:    retq25  %t0 = add i32 %a, 32 ; constant always on RHS26  %r = add i32 %t0, %b27  ret i32 %r28}29define i32 @sink_add_of_const_to_add1(i32 %a, i32 %b) {30; X32-LABEL: sink_add_of_const_to_add1:31; X32:       # %bb.0:32; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax33; X32-NEXT:    movl {{[0-9]+}}(%esp), %ecx34; X32-NEXT:    addl %ecx, %eax35; X32-NEXT:    addl $32, %eax36; X32-NEXT:    retl37;38; X64-LABEL: sink_add_of_const_to_add1:39; X64:       # %bb.0:40; X64-NEXT:    # kill: def $esi killed $esi def $rsi41; X64-NEXT:    # kill: def $edi killed $edi def $rdi42; X64-NEXT:    leal 32(%rdi,%rsi), %eax43; X64-NEXT:    retq44  %t0 = add i32 %a, 32 ; constant always on RHS45  %r = add i32 %b, %t046  ret i32 %r47}48 49; add (sub %x, C), %y50; Outer 'add' is commutative - 2 variants.51 52define i32 @sink_sub_of_const_to_add0(i32 %a, i32 %b) {53; X32-LABEL: sink_sub_of_const_to_add0:54; X32:       # %bb.0:55; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax56; X32-NEXT:    movl {{[0-9]+}}(%esp), %ecx57; X32-NEXT:    addl %ecx, %eax58; X32-NEXT:    addl $-32, %eax59; X32-NEXT:    retl60;61; X64-LABEL: sink_sub_of_const_to_add0:62; X64:       # %bb.0:63; X64-NEXT:    # kill: def $esi killed $esi def $rsi64; X64-NEXT:    # kill: def $edi killed $edi def $rdi65; X64-NEXT:    leal -32(%rdi,%rsi), %eax66; X64-NEXT:    retq67  %t0 = sub i32 %a, 3268  %r = add i32 %t0, %b69  ret i32 %r70}71define i32 @sink_sub_of_const_to_add1(i32 %a, i32 %b) {72; X32-LABEL: sink_sub_of_const_to_add1:73; X32:       # %bb.0:74; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax75; X32-NEXT:    movl {{[0-9]+}}(%esp), %ecx76; X32-NEXT:    addl %ecx, %eax77; X32-NEXT:    addl $-32, %eax78; X32-NEXT:    retl79;80; X64-LABEL: sink_sub_of_const_to_add1:81; X64:       # %bb.0:82; X64-NEXT:    # kill: def $esi killed $esi def $rsi83; X64-NEXT:    # kill: def $edi killed $edi def $rdi84; X64-NEXT:    leal -32(%rdi,%rsi), %eax85; X64-NEXT:    retq86  %t0 = sub i32 %a, 3287  %r = add i32 %b, %t088  ret i32 %r89}90 91; add (sub C, %x), %y92; Outer 'add' is commutative - 2 variants.93 94define i32 @sink_sub_from_const_to_add0(i32 %a, i32 %b) {95; X32-LABEL: sink_sub_from_const_to_add0:96; X32:       # %bb.0:97; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax98; X32-NEXT:    subl {{[0-9]+}}(%esp), %eax99; X32-NEXT:    addl $32, %eax100; X32-NEXT:    retl101;102; X64-LABEL: sink_sub_from_const_to_add0:103; X64:       # %bb.0:104; X64-NEXT:    # kill: def $esi killed $esi def $rsi105; X64-NEXT:    subl %edi, %esi106; X64-NEXT:    leal 32(%rsi), %eax107; X64-NEXT:    retq108  %t0 = sub i32 32, %a109  %r = add i32 %t0, %b110  ret i32 %r111}112define i32 @sink_sub_from_const_to_add1(i32 %a, i32 %b) {113; X32-LABEL: sink_sub_from_const_to_add1:114; X32:       # %bb.0:115; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax116; X32-NEXT:    subl {{[0-9]+}}(%esp), %eax117; X32-NEXT:    addl $32, %eax118; X32-NEXT:    retl119;120; X64-LABEL: sink_sub_from_const_to_add1:121; X64:       # %bb.0:122; X64-NEXT:    # kill: def $esi killed $esi def $rsi123; X64-NEXT:    subl %edi, %esi124; X64-NEXT:    leal 32(%rsi), %eax125; X64-NEXT:    retq126  %t0 = sub i32 32, %a127  %r = add i32 %b, %t0128  ret i32 %r129}130 131; sub (add %x, C), %y132; sub %y, (add %x, C)133 134define i32 @sink_add_of_const_to_sub(i32 %a, i32 %b) {135; X32-LABEL: sink_add_of_const_to_sub:136; X32:       # %bb.0:137; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax138; X32-NEXT:    subl {{[0-9]+}}(%esp), %eax139; X32-NEXT:    addl $32, %eax140; X32-NEXT:    retl141;142; X64-LABEL: sink_add_of_const_to_sub:143; X64:       # %bb.0:144; X64-NEXT:    # kill: def $edi killed $edi def $rdi145; X64-NEXT:    subl %esi, %edi146; X64-NEXT:    leal 32(%rdi), %eax147; X64-NEXT:    retq148  %t0 = add i32 %a, 32 ; constant always on RHS149  %r = sub i32 %t0, %b150  ret i32 %r151}152define i32 @sink_add_of_const_to_sub2(i32 %a, i32 %b) {153; X32-LABEL: sink_add_of_const_to_sub2:154; X32:       # %bb.0:155; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax156; X32-NEXT:    subl {{[0-9]+}}(%esp), %eax157; X32-NEXT:    addl $-32, %eax158; X32-NEXT:    retl159;160; X64-LABEL: sink_add_of_const_to_sub2:161; X64:       # %bb.0:162; X64-NEXT:    # kill: def $esi killed $esi def $rsi163; X64-NEXT:    subl %edi, %esi164; X64-NEXT:    leal -32(%rsi), %eax165; X64-NEXT:    retq166  %t0 = add i32 %a, 32 ; constant always on RHS167  %r = sub i32 %b, %t0168  ret i32 %r169}170 171; sub (sub %x, C), %y172; sub %y, (sub %x, C)173 174define i32 @sink_sub_of_const_to_sub(i32 %a, i32 %b) {175; X32-LABEL: sink_sub_of_const_to_sub:176; X32:       # %bb.0:177; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax178; X32-NEXT:    subl {{[0-9]+}}(%esp), %eax179; X32-NEXT:    addl $-32, %eax180; X32-NEXT:    retl181;182; X64-LABEL: sink_sub_of_const_to_sub:183; X64:       # %bb.0:184; X64-NEXT:    # kill: def $edi killed $edi def $rdi185; X64-NEXT:    subl %esi, %edi186; X64-NEXT:    leal -32(%rdi), %eax187; X64-NEXT:    retq188  %t0 = sub i32 %a, 32189  %r = sub i32 %t0, %b190  ret i32 %r191}192define i32 @sink_sub_of_const_to_sub2(i32 %a, i32 %b) {193; X32-LABEL: sink_sub_of_const_to_sub2:194; X32:       # %bb.0:195; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax196; X32-NEXT:    subl {{[0-9]+}}(%esp), %eax197; X32-NEXT:    addl $32, %eax198; X32-NEXT:    retl199;200; X64-LABEL: sink_sub_of_const_to_sub2:201; X64:       # %bb.0:202; X64-NEXT:    # kill: def $esi killed $esi def $rsi203; X64-NEXT:    subl %edi, %esi204; X64-NEXT:    leal 32(%rsi), %eax205; X64-NEXT:    retq206  %t0 = sub i32 %a, 32207  %r = sub i32 %b, %t0208  ret i32 %r209}210 211; sub (sub C, %x), %y212; sub %y, (sub C, %x)213 214define i32 @sink_sub_from_const_to_sub(i32 %a, i32 %b) {215; X32-LABEL: sink_sub_from_const_to_sub:216; X32:       # %bb.0:217; X32-NEXT:    movl {{[0-9]+}}(%esp), %ecx218; X32-NEXT:    addl {{[0-9]+}}(%esp), %ecx219; X32-NEXT:    movl $32, %eax220; X32-NEXT:    subl %ecx, %eax221; X32-NEXT:    retl222;223; X64-LABEL: sink_sub_from_const_to_sub:224; X64:       # %bb.0:225; X64-NEXT:    addl %esi, %edi226; X64-NEXT:    movl $32, %eax227; X64-NEXT:    subl %edi, %eax228; X64-NEXT:    retq229  %t0 = sub i32 32, %a230  %r = sub i32 %t0, %b231  ret i32 %r232}233define i32 @sink_sub_from_const_to_sub2(i32 %a, i32 %b) {234; X32-LABEL: sink_sub_from_const_to_sub2:235; X32:       # %bb.0:236; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax237; X32-NEXT:    movl {{[0-9]+}}(%esp), %ecx238; X32-NEXT:    addl %ecx, %eax239; X32-NEXT:    addl $-32, %eax240; X32-NEXT:    retl241;242; X64-LABEL: sink_sub_from_const_to_sub2:243; X64:       # %bb.0:244; X64-NEXT:    # kill: def $esi killed $esi def $rsi245; X64-NEXT:    # kill: def $edi killed $edi def $rdi246; X64-NEXT:    leal -32(%rdi,%rsi), %eax247; X64-NEXT:    retq248  %t0 = sub i32 32, %a249  %r = sub i32 %b, %t0250  ret i32 %r251}252 253;------------------------------------------------------------------------------;254; Basic vector tests. Here it is easier to see where the constant operand is.255;------------------------------------------------------------------------------;256 257; add (add %x, C), %y258; Outer 'add' is commutative - 2 variants.259 260define <4 x i32> @vec_sink_add_of_const_to_add0(<4 x i32> %a, <4 x i32> %b) {261; X32-LABEL: vec_sink_add_of_const_to_add0:262; X32:       # %bb.0:263; X32-NEXT:    paddd %xmm1, %xmm0264; X32-NEXT:    paddd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0265; X32-NEXT:    retl266;267; X64-LABEL: vec_sink_add_of_const_to_add0:268; X64:       # %bb.0:269; X64-NEXT:    paddd %xmm1, %xmm0270; X64-NEXT:    paddd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0271; X64-NEXT:    retq272  %t0 = add <4 x i32> %a, <i32 42, i32 24, i32 undef, i32 46> ; constant always on RHS273  %r = add <4 x i32> %t0, %b274  ret <4 x i32> %r275}276define <4 x i32> @vec_sink_add_of_const_to_add1(<4 x i32> %a, <4 x i32> %b) {277; X32-LABEL: vec_sink_add_of_const_to_add1:278; X32:       # %bb.0:279; X32-NEXT:    paddd %xmm1, %xmm0280; X32-NEXT:    paddd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0281; X32-NEXT:    retl282;283; X64-LABEL: vec_sink_add_of_const_to_add1:284; X64:       # %bb.0:285; X64-NEXT:    paddd %xmm1, %xmm0286; X64-NEXT:    paddd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0287; X64-NEXT:    retq288  %t0 = add <4 x i32> %a, <i32 42, i32 24, i32 undef, i32 46> ; constant always on RHS289  %r = add <4 x i32> %b, %t0290  ret <4 x i32> %r291}292 293; add (sub %x, C), %y294; Outer 'add' is commutative - 2 variants.295 296define <4 x i32> @vec_sink_sub_of_const_to_add0(<4 x i32> %a, <4 x i32> %b) {297; X32-LABEL: vec_sink_sub_of_const_to_add0:298; X32:       # %bb.0:299; X32-NEXT:    paddd %xmm1, %xmm0300; X32-NEXT:    psubd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0301; X32-NEXT:    retl302;303; X64-LABEL: vec_sink_sub_of_const_to_add0:304; X64:       # %bb.0:305; X64-NEXT:    paddd %xmm1, %xmm0306; X64-NEXT:    psubd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0307; X64-NEXT:    retq308  %t0 = sub <4 x i32> %a, <i32 42, i32 24, i32 undef, i32 46>309  %r = add <4 x i32> %t0, %b310  ret <4 x i32> %r311}312define <4 x i32> @vec_sink_sub_of_const_to_add1(<4 x i32> %a, <4 x i32> %b) {313; X32-LABEL: vec_sink_sub_of_const_to_add1:314; X32:       # %bb.0:315; X32-NEXT:    paddd %xmm1, %xmm0316; X32-NEXT:    psubd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0317; X32-NEXT:    retl318;319; X64-LABEL: vec_sink_sub_of_const_to_add1:320; X64:       # %bb.0:321; X64-NEXT:    paddd %xmm1, %xmm0322; X64-NEXT:    psubd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0323; X64-NEXT:    retq324  %t0 = sub <4 x i32> %a, <i32 42, i32 24, i32 undef, i32 46>325  %r = add <4 x i32> %b, %t0326  ret <4 x i32> %r327}328 329; add (sub C, %x), %y330; Outer 'add' is commutative - 2 variants.331 332define <4 x i32> @vec_sink_sub_from_const_to_add0(<4 x i32> %a, <4 x i32> %b) {333; X32-LABEL: vec_sink_sub_from_const_to_add0:334; X32:       # %bb.0:335; X32-NEXT:    psubd %xmm0, %xmm1336; X32-NEXT:    paddd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm1337; X32-NEXT:    movdqa %xmm1, %xmm0338; X32-NEXT:    retl339;340; X64-LABEL: vec_sink_sub_from_const_to_add0:341; X64:       # %bb.0:342; X64-NEXT:    psubd %xmm0, %xmm1343; X64-NEXT:    paddd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1344; X64-NEXT:    movdqa %xmm1, %xmm0345; X64-NEXT:    retq346  %t0 = sub <4 x i32> <i32 42, i32 24, i32 undef, i32 46>, %a347  %r = add <4 x i32> %t0, %b348  ret <4 x i32> %r349}350define <4 x i32> @vec_sink_sub_from_const_to_add1(<4 x i32> %a, <4 x i32> %b) {351; X32-LABEL: vec_sink_sub_from_const_to_add1:352; X32:       # %bb.0:353; X32-NEXT:    psubd %xmm0, %xmm1354; X32-NEXT:    paddd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm1355; X32-NEXT:    movdqa %xmm1, %xmm0356; X32-NEXT:    retl357;358; X64-LABEL: vec_sink_sub_from_const_to_add1:359; X64:       # %bb.0:360; X64-NEXT:    psubd %xmm0, %xmm1361; X64-NEXT:    paddd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1362; X64-NEXT:    movdqa %xmm1, %xmm0363; X64-NEXT:    retq364  %t0 = sub <4 x i32> <i32 42, i32 24, i32 undef, i32 46>, %a365  %r = add <4 x i32> %b, %t0366  ret <4 x i32> %r367}368 369; sub (add %x, C), %y370; sub %y, (add %x, C)371 372define <4 x i32> @vec_sink_add_of_const_to_sub(<4 x i32> %a, <4 x i32> %b) {373; X32-LABEL: vec_sink_add_of_const_to_sub:374; X32:       # %bb.0:375; X32-NEXT:    psubd %xmm1, %xmm0376; X32-NEXT:    paddd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0377; X32-NEXT:    retl378;379; X64-LABEL: vec_sink_add_of_const_to_sub:380; X64:       # %bb.0:381; X64-NEXT:    psubd %xmm1, %xmm0382; X64-NEXT:    paddd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0383; X64-NEXT:    retq384  %t0 = add <4 x i32> %a, <i32 42, i32 24, i32 undef, i32 46> ; constant always on RHS385  %r = sub <4 x i32> %t0, %b386  ret <4 x i32> %r387}388define <4 x i32> @vec_sink_add_of_const_to_sub2(<4 x i32> %a, <4 x i32> %b) {389; X32-LABEL: vec_sink_add_of_const_to_sub2:390; X32:       # %bb.0:391; X32-NEXT:    psubd %xmm0, %xmm1392; X32-NEXT:    psubd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm1393; X32-NEXT:    movdqa %xmm1, %xmm0394; X32-NEXT:    retl395;396; X64-LABEL: vec_sink_add_of_const_to_sub2:397; X64:       # %bb.0:398; X64-NEXT:    psubd %xmm0, %xmm1399; X64-NEXT:    psubd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1400; X64-NEXT:    movdqa %xmm1, %xmm0401; X64-NEXT:    retq402  %t0 = add <4 x i32> %a, <i32 42, i32 24, i32 undef, i32 46> ; constant always on RHS403  %r = sub <4 x i32> %b, %t0404  ret <4 x i32> %r405}406 407; sub (sub %x, C), %y408; sub %y, (sub %x, C)409 410define <4 x i32> @vec_sink_sub_of_const_to_sub(<4 x i32> %a, <4 x i32> %b) {411; X32-LABEL: vec_sink_sub_of_const_to_sub:412; X32:       # %bb.0:413; X32-NEXT:    psubd %xmm1, %xmm0414; X32-NEXT:    psubd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0415; X32-NEXT:    retl416;417; X64-LABEL: vec_sink_sub_of_const_to_sub:418; X64:       # %bb.0:419; X64-NEXT:    psubd %xmm1, %xmm0420; X64-NEXT:    psubd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0421; X64-NEXT:    retq422  %t0 = sub <4 x i32> %a, <i32 42, i32 24, i32 undef, i32 46>423  %r = sub <4 x i32> %t0, %b424  ret <4 x i32> %r425}426define <4 x i32> @vec_sink_sub_of_const_to_sub2(<4 x i32> %a, <4 x i32> %b) {427; X32-LABEL: vec_sink_sub_of_const_to_sub2:428; X32:       # %bb.0:429; X32-NEXT:    psubd %xmm0, %xmm1430; X32-NEXT:    paddd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm1431; X32-NEXT:    movdqa %xmm1, %xmm0432; X32-NEXT:    retl433;434; X64-LABEL: vec_sink_sub_of_const_to_sub2:435; X64:       # %bb.0:436; X64-NEXT:    psubd %xmm0, %xmm1437; X64-NEXT:    paddd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1438; X64-NEXT:    movdqa %xmm1, %xmm0439; X64-NEXT:    retq440  %t0 = sub <4 x i32> %a, <i32 42, i32 24, i32 undef, i32 46>441  %r = sub <4 x i32> %b, %t0442  ret <4 x i32> %r443}444 445; sub (sub C, %x), %y446; sub %y, (sub C, %x)447 448define <4 x i32> @vec_sink_sub_from_const_to_sub(<4 x i32> %a, <4 x i32> %b) {449; ALL-LABEL: vec_sink_sub_from_const_to_sub:450; ALL:       # %bb.0:451; ALL-NEXT:    movdqa {{.*#+}} xmm2 = [42,24,u,46]452; ALL-NEXT:    paddd %xmm1, %xmm0453; ALL-NEXT:    psubd %xmm0, %xmm2454; ALL-NEXT:    movdqa %xmm2, %xmm0455; ALL-NEXT:    ret{{[l|q]}}456  %t0 = sub <4 x i32> <i32 42, i32 24, i32 undef, i32 46>, %a457  %r = sub <4 x i32> %t0, %b458  ret <4 x i32> %r459}460define <4 x i32> @vec_sink_sub_from_const_to_sub2(<4 x i32> %a, <4 x i32> %b) {461; X32-LABEL: vec_sink_sub_from_const_to_sub2:462; X32:       # %bb.0:463; X32-NEXT:    paddd %xmm1, %xmm0464; X32-NEXT:    psubd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0465; X32-NEXT:    retl466;467; X64-LABEL: vec_sink_sub_from_const_to_sub2:468; X64:       # %bb.0:469; X64-NEXT:    paddd %xmm1, %xmm0470; X64-NEXT:    psubd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0471; X64-NEXT:    retq472  %t0 = sub <4 x i32> <i32 42, i32 24, i32 undef, i32 46>, %a473  %r = sub <4 x i32> %b, %t0474  ret <4 x i32> %r475}476