brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.0 KiB · a7a54fd Raw
95 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc < %s -mtriple=i686-unknown-unknown | FileCheck %s --check-prefix=X863; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s --check-prefix=X644 5define i64 @test_add_i64_i16_const(i16 %a) nounwind {6; X86-LABEL: test_add_i64_i16_const:7; X86:       # %bb.0:8; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %eax9; X86-NEXT:    addl $42, %eax10; X86-NEXT:    xorl %edx, %edx11; X86-NEXT:    retl12;13; X64-LABEL: test_add_i64_i16_const:14; X64:       # %bb.0:15; X64-NEXT:    movzwl %di, %eax16; X64-NEXT:    addq $42, %rax17; X64-NEXT:    retq18  %zext_a = zext i16 %a to i6419  %sum = add nuw nsw i64 %zext_a, 4220  ret i64 %sum21}22 23; TODO: First 48 bits are all zeros so we can safely truncate to 32 bit additon24define i64 @test_add_i64_i16_zext(i16 %a, i16 %b) nounwind {25; X86-LABEL: test_add_i64_i16_zext:26; X86:       # %bb.0:27; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %ecx28; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %eax29; X86-NEXT:    addl %ecx, %eax30; X86-NEXT:    xorl %edx, %edx31; X86-NEXT:    retl32;33; X64-LABEL: test_add_i64_i16_zext:34; X64:       # %bb.0:35; X64-NEXT:    movzwl %di, %ecx36; X64-NEXT:    movzwl %si, %eax37; X64-NEXT:    addq %rcx, %rax38; X64-NEXT:    retq39  %zext_a = zext i16 %a to i6440  %zext_b = zext i16 %b to i6441  %sum = add nuw nsw i64 %zext_a, %zext_b42  ret i64 %sum43}44 45; Negative: Set the 32nd bit of a to force 64 bit addition, we do not truncate to 32 bit addition in this case46define i64 @negative_test_add_i64_i16(i16 %a) nounwind {47; X86-LABEL: negative_test_add_i64_i16:48; X86:       # %bb.0:49; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %eax50; X86-NEXT:    addl $42, %eax51; X86-NEXT:    movl $1, %edx52; X86-NEXT:    retl53;54; X64-LABEL: negative_test_add_i64_i16:55; X64:       # %bb.0:56; X64-NEXT:    movzwl %di, %ecx57; X64-NEXT:    movabsq $4294967338, %rax # imm = 0x10000002A58; X64-NEXT:    addq %rcx, %rax59; X64-NEXT:    retq60  %zext_a = zext i16 %a to i6461  %or_a = or i64 %zext_a, 429496729662  %sum = add nuw nsw i64 %or_a, 4263  ret i64 %sum64}65 66; Negative: We don't truncate to 32 bit addition in case of sign extension67define i64 @negative_test_add_i64_i16_sext(i16 %a, i16 %b) nounwind {68; X86-LABEL: negative_test_add_i64_i16_sext:69; X86:       # %bb.0:70; X86-NEXT:    pushl %esi71; X86-NEXT:    movswl {{[0-9]+}}(%esp), %ecx72; X86-NEXT:    movl %ecx, %esi73; X86-NEXT:    sarl $31, %esi74; X86-NEXT:    movswl {{[0-9]+}}(%esp), %eax75; X86-NEXT:    movl %eax, %edx76; X86-NEXT:    sarl $31, %edx77; X86-NEXT:    addl %ecx, %eax78; X86-NEXT:    adcl %esi, %edx79; X86-NEXT:    popl %esi80; X86-NEXT:    retl81;82; X64-LABEL: negative_test_add_i64_i16_sext:83; X64:       # %bb.0:84; X64-NEXT:    # kill: def $esi killed $esi def $rsi85; X64-NEXT:    # kill: def $edi killed $edi def $rdi86; X64-NEXT:    movswq %di, %rcx87; X64-NEXT:    movswq %si, %rax88; X64-NEXT:    addq %rcx, %rax89; X64-NEXT:    retq90  %sext_a = sext i16 %a to i6491  %sext_b = sext i16 %b to i6492  %sum = add nuw nsw i64 %sext_a, %sext_b93  ret i64 %sum94}95