297 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc < %s -mtriple=i686-unknown-unknown --show-mc-encoding | FileCheck %s --check-prefix=X863; RUN: llc < %s -mtriple=x86_64-unknown --show-mc-encoding | FileCheck %s --check-prefix=X644 5define void @adc_load_store_64_15(ptr inreg %x, ptr inreg %x2, i64 inreg %y) nounwind {6; X86-LABEL: adc_load_store_64_15:7; X86: # %bb.0:8; X86-NEXT: pushl %esi # encoding: [0x56]9; X86-NEXT: movl {{[0-9]+}}(%esp), %esi # encoding: [0x8b,0x74,0x24,0x08]10; X86-NEXT: addl $1, %ecx # encoding: [0x83,0xc1,0x01]11; X86-NEXT: adcl $0, %esi # encoding: [0x83,0xd6,0x00]12; X86-NEXT: adcl $15, (%eax) # encoding: [0x83,0x10,0x0f]13; X86-NEXT: adcl $0, 4(%eax) # encoding: [0x83,0x50,0x04,0x00]14; X86-NEXT: setb %al # encoding: [0x0f,0x92,0xc0]15; X86-NEXT: movzbl %al, %eax # encoding: [0x0f,0xb6,0xc0]16; X86-NEXT: movl %eax, (%edx) # encoding: [0x89,0x02]17; X86-NEXT: movl $0, 4(%edx) # encoding: [0xc7,0x42,0x04,0x00,0x00,0x00,0x00]18; X86-NEXT: popl %esi # encoding: [0x5e]19; X86-NEXT: retl # encoding: [0xc3]20;21; X64-LABEL: adc_load_store_64_15:22; X64: # %bb.0:23; X64-NEXT: addq $1, %rdx # encoding: [0x48,0x83,0xc2,0x01]24; X64-NEXT: adcq $15, (%rdi) # encoding: [0x48,0x83,0x17,0x0f]25; X64-NEXT: setb %al # encoding: [0x0f,0x92,0xc0]26; X64-NEXT: movzbl %al, %eax # encoding: [0x0f,0xb6,0xc0]27; X64-NEXT: movq %rax, (%rsi) # encoding: [0x48,0x89,0x06]28; X64-NEXT: retq # encoding: [0xc3]29 %vx = load i64, ptr %x30 %zvx = zext i64 %vx to i19231 %szvx = shl i192 %zvx, 6432 %zy = zext i64 %y to i19233 %op = or i192 %szvx, %zy34 %zsum = add i192 %op, 276701161105643274241 ; 0x0000_0000_0000_0000__0000_0000_0000_000F__0000_0000_0000_000135 %ssum = lshr i192 %zsum, 6436 %val = trunc i192 %ssum to i6437 store i64 %val, ptr %x38 %ssum2 = lshr i192 %zsum, 12839 %val2 = trunc i192 %ssum2 to i6440 store i64 %val2, ptr %x241 ret void42}43 44define void @adc_load_store_64_0x1000F(ptr inreg %x, ptr inreg %x2, i64 inreg %y) nounwind {45; X86-LABEL: adc_load_store_64_0x1000F:46; X86: # %bb.0:47; X86-NEXT: pushl %esi # encoding: [0x56]48; X86-NEXT: movl {{[0-9]+}}(%esp), %esi # encoding: [0x8b,0x74,0x24,0x08]49; X86-NEXT: addl $1, %ecx # encoding: [0x83,0xc1,0x01]50; X86-NEXT: adcl $0, %esi # encoding: [0x83,0xd6,0x00]51; X86-NEXT: adcl $65551, (%eax) # encoding: [0x81,0x10,0x0f,0x00,0x01,0x00]52; X86-NEXT: # imm = 0x1000F53; X86-NEXT: adcl $0, 4(%eax) # encoding: [0x83,0x50,0x04,0x00]54; X86-NEXT: setb %al # encoding: [0x0f,0x92,0xc0]55; X86-NEXT: movzbl %al, %eax # encoding: [0x0f,0xb6,0xc0]56; X86-NEXT: movl %eax, (%edx) # encoding: [0x89,0x02]57; X86-NEXT: movl $0, 4(%edx) # encoding: [0xc7,0x42,0x04,0x00,0x00,0x00,0x00]58; X86-NEXT: popl %esi # encoding: [0x5e]59; X86-NEXT: retl # encoding: [0xc3]60;61; X64-LABEL: adc_load_store_64_0x1000F:62; X64: # %bb.0:63; X64-NEXT: addq $1, %rdx # encoding: [0x48,0x83,0xc2,0x01]64; X64-NEXT: adcq $65551, (%rdi) # encoding: [0x48,0x81,0x17,0x0f,0x00,0x01,0x00]65; X64-NEXT: # imm = 0x1000F66; X64-NEXT: setb %al # encoding: [0x0f,0x92,0xc0]67; X64-NEXT: movzbl %al, %eax # encoding: [0x0f,0xb6,0xc0]68; X64-NEXT: movq %rax, (%rsi) # encoding: [0x48,0x89,0x06]69; X64-NEXT: retq # encoding: [0xc3]70 %vx = load i64, ptr %x71 %zvx = zext i64 %vx to i19272 %szvx = shl i192 %zvx, 6473 %zy = zext i64 %y to i19274 %op = or i192 %szvx, %zy75 %zsum = add i192 %op, 1209202520775734817980417 ; 0x0000_0000_0000_0000__0000_0000_0001_000F__0000_0000_0000_000176 %ssum = lshr i192 %zsum, 6477 %val = trunc i192 %ssum to i6478 store i64 %val, ptr %x79 %ssum2 = lshr i192 %zsum, 12880 %val2 = trunc i192 %ssum2 to i6481 store i64 %val2, ptr %x282 ret void83}84 85define void @adc_load_store_64_0x100001000F(ptr inreg %x, ptr inreg %x2, i64 inreg %y) nounwind {86; X86-LABEL: adc_load_store_64_0x100001000F:87; X86: # %bb.0:88; X86-NEXT: pushl %esi # encoding: [0x56]89; X86-NEXT: movl {{[0-9]+}}(%esp), %esi # encoding: [0x8b,0x74,0x24,0x08]90; X86-NEXT: addl $1, %ecx # encoding: [0x83,0xc1,0x01]91; X86-NEXT: adcl $0, %esi # encoding: [0x83,0xd6,0x00]92; X86-NEXT: adcl $15, (%eax) # encoding: [0x83,0x10,0x0f]93; X86-NEXT: adcl $16, 4(%eax) # encoding: [0x83,0x50,0x04,0x10]94; X86-NEXT: setb %al # encoding: [0x0f,0x92,0xc0]95; X86-NEXT: movzbl %al, %eax # encoding: [0x0f,0xb6,0xc0]96; X86-NEXT: movl %eax, (%edx) # encoding: [0x89,0x02]97; X86-NEXT: movl $0, 4(%edx) # encoding: [0xc7,0x42,0x04,0x00,0x00,0x00,0x00]98; X86-NEXT: popl %esi # encoding: [0x5e]99; X86-NEXT: retl # encoding: [0xc3]100;101; X64-LABEL: adc_load_store_64_0x100001000F:102; X64: # %bb.0:103; X64-NEXT: addq $1, %rdx # encoding: [0x48,0x83,0xc2,0x01]104; X64-NEXT: movabsq $68719476751, %rax # encoding: [0x48,0xb8,0x0f,0x00,0x00,0x00,0x10,0x00,0x00,0x00]105; X64-NEXT: # imm = 0x100000000F106; X64-NEXT: adcq %rax, (%rdi) # encoding: [0x48,0x11,0x07]107; X64-NEXT: setb %al # encoding: [0x0f,0x92,0xc0]108; X64-NEXT: movzbl %al, %eax # encoding: [0x0f,0xb6,0xc0]109; X64-NEXT: movq %rax, (%rsi) # encoding: [0x48,0x89,0x06]110; X64-NEXT: retq # encoding: [0xc3]111 %vx = load i64, ptr %x112 %zvx = zext i64 %vx to i192113 %szvx = shl i192 %zvx, 64114 %zy = zext i64 %y to i192115 %op = or i192 %szvx, %zy116 %zsum = add i192 %op, 1267650600504930562602346479617 ; 0x0000_0000_0000_0000__0000_0010_0000_000F__0000_0000_0000_0001117 %ssum = lshr i192 %zsum, 64118 %val = trunc i192 %ssum to i64119 store i64 %val, ptr %x120 %ssum2 = lshr i192 %zsum, 128121 %val2 = trunc i192 %ssum2 to i64122 store i64 %val2, ptr %x2123 ret void124}125 126define void @adc_load_store_32_127(ptr inreg %x, ptr inreg %x2, i32 inreg %y) nounwind {127; X86-LABEL: adc_load_store_32_127:128; X86: # %bb.0:129; X86-NEXT: addl $1, %ecx # encoding: [0x83,0xc1,0x01]130; X86-NEXT: adcl $127, (%eax) # encoding: [0x83,0x10,0x7f]131; X86-NEXT: setb %al # encoding: [0x0f,0x92,0xc0]132; X86-NEXT: movzbl %al, %eax # encoding: [0x0f,0xb6,0xc0]133; X86-NEXT: movl %eax, (%edx) # encoding: [0x89,0x02]134; X86-NEXT: retl # encoding: [0xc3]135;136; X64-LABEL: adc_load_store_32_127:137; X64: # %bb.0:138; X64-NEXT: movl (%rdi), %eax # encoding: [0x8b,0x07]139; X64-NEXT: shlq $32, %rax # encoding: [0x48,0xc1,0xe0,0x20]140; X64-NEXT: movl %edx, %ecx # encoding: [0x89,0xd1]141; X64-NEXT: orq %rax, %rcx # encoding: [0x48,0x09,0xc1]142; X64-NEXT: movabsq $545460846593, %rax # encoding: [0x48,0xb8,0x01,0x00,0x00,0x00,0x7f,0x00,0x00,0x00]143; X64-NEXT: # imm = 0x7F00000001144; X64-NEXT: xorl %edx, %edx # encoding: [0x31,0xd2]145; X64-NEXT: addq %rcx, %rax # encoding: [0x48,0x01,0xc8]146; X64-NEXT: setb %dl # encoding: [0x0f,0x92,0xc2]147; X64-NEXT: shrq $32, %rax # encoding: [0x48,0xc1,0xe8,0x20]148; X64-NEXT: movl %eax, (%rdi) # encoding: [0x89,0x07]149; X64-NEXT: movl %edx, (%rsi) # encoding: [0x89,0x16]150; X64-NEXT: retq # encoding: [0xc3]151 %vx = load i32, ptr %x152 %zvx = zext i32 %vx to i96153 %szvx = shl i96 %zvx, 32154 %zy = zext i32 %y to i96155 %op = or i96 %szvx, %zy156 %zsum = add i96 %op, 545460846593 ; 0x0000_0000__0000_007F__0000_0001157 %ssum = lshr i96 %zsum, 32158 %val = trunc i96 %ssum to i32159 store i32 %val, ptr %x160 %ssum2 = lshr i96 %zsum, 64161 %val2 = trunc i96 %ssum2 to i32162 store i32 %val2, ptr %x2163 ret void164}165 166define void @adc_load_store_32_128(ptr inreg %x, ptr inreg %x2, i32 inreg %y) nounwind {167; X86-LABEL: adc_load_store_32_128:168; X86: # %bb.0:169; X86-NEXT: addl $1, %ecx # encoding: [0x83,0xc1,0x01]170; X86-NEXT: adcl $128, (%eax) # encoding: [0x81,0x10,0x80,0x00,0x00,0x00]171; X86-NEXT: setb %al # encoding: [0x0f,0x92,0xc0]172; X86-NEXT: movzbl %al, %eax # encoding: [0x0f,0xb6,0xc0]173; X86-NEXT: movl %eax, (%edx) # encoding: [0x89,0x02]174; X86-NEXT: retl # encoding: [0xc3]175;176; X64-LABEL: adc_load_store_32_128:177; X64: # %bb.0:178; X64-NEXT: movl (%rdi), %eax # encoding: [0x8b,0x07]179; X64-NEXT: shlq $32, %rax # encoding: [0x48,0xc1,0xe0,0x20]180; X64-NEXT: movl %edx, %ecx # encoding: [0x89,0xd1]181; X64-NEXT: orq %rax, %rcx # encoding: [0x48,0x09,0xc1]182; X64-NEXT: movabsq $549755813889, %rax # encoding: [0x48,0xb8,0x01,0x00,0x00,0x00,0x80,0x00,0x00,0x00]183; X64-NEXT: # imm = 0x8000000001184; X64-NEXT: xorl %edx, %edx # encoding: [0x31,0xd2]185; X64-NEXT: addq %rcx, %rax # encoding: [0x48,0x01,0xc8]186; X64-NEXT: setb %dl # encoding: [0x0f,0x92,0xc2]187; X64-NEXT: shrq $32, %rax # encoding: [0x48,0xc1,0xe8,0x20]188; X64-NEXT: movl %eax, (%rdi) # encoding: [0x89,0x07]189; X64-NEXT: movl %edx, (%rsi) # encoding: [0x89,0x16]190; X64-NEXT: retq # encoding: [0xc3]191 %vx = load i32, ptr %x192 %zvx = zext i32 %vx to i96193 %szvx = shl i96 %zvx, 32194 %zy = zext i32 %y to i96195 %op = or i96 %szvx, %zy196 %zsum = add i96 %op, 549755813889 ; 0x0000_0000__0000_0080__0000_0001197 %ssum = lshr i96 %zsum, 32198 %val = trunc i96 %ssum to i32199 store i32 %val, ptr %x200 %ssum2 = lshr i96 %zsum, 64201 %val2 = trunc i96 %ssum2 to i32202 store i32 %val2, ptr %x2203 ret void204}205 206; These tests all verify the load-op-store fusion does not generate207; larger instructions than mainline DAG Instruction selection.208 209define void @adc_load_store_8_15(i64 inreg %ca, i64 inreg %cb, ptr inreg %x) nounwind {210; X86-LABEL: adc_load_store_8_15:211; X86: # %bb.0:212; X86-NEXT: pushl %esi # encoding: [0x56]213; X86-NEXT: movl {{[0-9]+}}(%esp), %esi # encoding: [0x8b,0x74,0x24,0x0c]214; X86-NEXT: addl %ecx, %eax # encoding: [0x01,0xc8]215; X86-NEXT: adcl {{[0-9]+}}(%esp), %edx # encoding: [0x13,0x54,0x24,0x08]216; X86-NEXT: adcb $15, (%esi) # encoding: [0x80,0x16,0x0f]217; X86-NEXT: popl %esi # encoding: [0x5e]218; X86-NEXT: retl # encoding: [0xc3]219;220; X64-LABEL: adc_load_store_8_15:221; X64: # %bb.0:222; X64-NEXT: addq %rsi, %rdi # encoding: [0x48,0x01,0xf7]223; X64-NEXT: adcb $15, (%rdx) # encoding: [0x80,0x12,0x0f]224; X64-NEXT: retq # encoding: [0xc3]225 %zca = zext i64 %ca to i65226 %zcb = zext i64 %cb to i65227 %zc = add i65 %zca, %zcb228 %ec = lshr i65 %zc, 64229 %c = trunc i65 %ec to i1230 %cc = zext i1 %c to i8231 %vx = load i8, ptr %x232 %cc_off = add i8 15, %cc233 %vsum = add i8 %vx, %cc_off234 store i8 %vsum, ptr %x235 ret void236}237 238define void @adc_load_store_16_15(i64 inreg %ca, i64 inreg %cb, ptr inreg %x) nounwind {239; X86-LABEL: adc_load_store_16_15:240; X86: # %bb.0:241; X86-NEXT: pushl %esi # encoding: [0x56]242; X86-NEXT: movl {{[0-9]+}}(%esp), %esi # encoding: [0x8b,0x74,0x24,0x0c]243; X86-NEXT: addl %ecx, %eax # encoding: [0x01,0xc8]244; X86-NEXT: adcl {{[0-9]+}}(%esp), %edx # encoding: [0x13,0x54,0x24,0x08]245; X86-NEXT: adcw $15, (%esi) # encoding: [0x66,0x83,0x16,0x0f]246; X86-NEXT: popl %esi # encoding: [0x5e]247; X86-NEXT: retl # encoding: [0xc3]248;249; X64-LABEL: adc_load_store_16_15:250; X64: # %bb.0:251; X64-NEXT: addq %rsi, %rdi # encoding: [0x48,0x01,0xf7]252; X64-NEXT: adcw $15, (%rdx) # encoding: [0x66,0x83,0x12,0x0f]253; X64-NEXT: retq # encoding: [0xc3]254 %zca = zext i64 %ca to i65255 %zcb = zext i64 %cb to i65256 %zc = add i65 %zca, %zcb257 %ec = lshr i65 %zc, 64258 %c = trunc i65 %ec to i1259 %cc = zext i1 %c to i16260 %vx = load i16, ptr %x261 %cc_off = add i16 15, %cc262 %vsum = add i16 %vx, %cc_off263 store i16 %vsum, ptr %x264 ret void265}266 267define void @adc_load_store_16_256(i64 inreg %ca, i64 inreg %cb, ptr inreg %x) nounwind {268; X86-LABEL: adc_load_store_16_256:269; X86: # %bb.0:270; X86-NEXT: pushl %esi # encoding: [0x56]271; X86-NEXT: movl {{[0-9]+}}(%esp), %esi # encoding: [0x8b,0x74,0x24,0x0c]272; X86-NEXT: addl %ecx, %eax # encoding: [0x01,0xc8]273; X86-NEXT: adcl {{[0-9]+}}(%esp), %edx # encoding: [0x13,0x54,0x24,0x08]274; X86-NEXT: adcw $256, (%esi) # encoding: [0x66,0x81,0x16,0x00,0x01]275; X86-NEXT: # imm = 0x100276; X86-NEXT: popl %esi # encoding: [0x5e]277; X86-NEXT: retl # encoding: [0xc3]278;279; X64-LABEL: adc_load_store_16_256:280; X64: # %bb.0:281; X64-NEXT: addq %rsi, %rdi # encoding: [0x48,0x01,0xf7]282; X64-NEXT: adcw $256, (%rdx) # encoding: [0x66,0x81,0x12,0x00,0x01]283; X64-NEXT: # imm = 0x100284; X64-NEXT: retq # encoding: [0xc3]285 %zca = zext i64 %ca to i65286 %zcb = zext i64 %cb to i65287 %zc = add i65 %zca, %zcb288 %ec = lshr i65 %zc, 64289 %c = trunc i65 %ec to i1290 %cc = zext i1 %c to i16291 %vx = load i16, ptr %x292 %cc_off = add i16 256, %cc293 %vsum = add i16 %vx, %cc_off294 store i16 %vsum, ptr %x295 ret void296}297