Home | History | Annotate | Download | only in R600
      1 ; RUN: llc -march=amdgcn -mcpu=SI -verify-machineinstrs< %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
      2 ; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs< %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
      3 ; RUN: llc -march=r600 -mcpu=cypress -verify-machineinstrs< %s
      4 
      5 declare { i32, i1 } @llvm.usub.with.overflow.i32(i32, i32) nounwind readnone
      6 declare { i64, i1 } @llvm.usub.with.overflow.i64(i64, i64) nounwind readnone
      7 
      8 ; FUNC-LABEL: {{^}}usubo_i64_zext:
      9 define void @usubo_i64_zext(i64 addrspace(1)* %out, i64 %a, i64 %b) nounwind {
     10   %usub = call { i64, i1 } @llvm.usub.with.overflow.i64(i64 %a, i64 %b) nounwind
     11   %val = extractvalue { i64, i1 } %usub, 0
     12   %carry = extractvalue { i64, i1 } %usub, 1
     13   %ext = zext i1 %carry to i64
     14   %add2 = add i64 %val, %ext
     15   store i64 %add2, i64 addrspace(1)* %out, align 8
     16   ret void
     17 }
     18 
     19 ; FUNC-LABEL: {{^}}s_usubo_i32:
     20 ; SI: s_sub_i32
     21 define void @s_usubo_i32(i32 addrspace(1)* %out, i1 addrspace(1)* %carryout, i32 %a, i32 %b) nounwind {
     22   %usub = call { i32, i1 } @llvm.usub.with.overflow.i32(i32 %a, i32 %b) nounwind
     23   %val = extractvalue { i32, i1 } %usub, 0
     24   %carry = extractvalue { i32, i1 } %usub, 1
     25   store i32 %val, i32 addrspace(1)* %out, align 4
     26   store i1 %carry, i1 addrspace(1)* %carryout
     27   ret void
     28 }
     29 
     30 ; FUNC-LABEL: {{^}}v_usubo_i32:
     31 ; SI: v_subrev_i32_e32
     32 define void @v_usubo_i32(i32 addrspace(1)* %out, i1 addrspace(1)* %carryout, i32 addrspace(1)* %aptr, i32 addrspace(1)* %bptr) nounwind {
     33   %a = load i32, i32 addrspace(1)* %aptr, align 4
     34   %b = load i32, i32 addrspace(1)* %bptr, align 4
     35   %usub = call { i32, i1 } @llvm.usub.with.overflow.i32(i32 %a, i32 %b) nounwind
     36   %val = extractvalue { i32, i1 } %usub, 0
     37   %carry = extractvalue { i32, i1 } %usub, 1
     38   store i32 %val, i32 addrspace(1)* %out, align 4
     39   store i1 %carry, i1 addrspace(1)* %carryout
     40   ret void
     41 }
     42 
     43 ; FUNC-LABEL: {{^}}s_usubo_i64:
     44 ; SI: s_sub_u32
     45 ; SI: s_subb_u32
     46 define void @s_usubo_i64(i64 addrspace(1)* %out, i1 addrspace(1)* %carryout, i64 %a, i64 %b) nounwind {
     47   %usub = call { i64, i1 } @llvm.usub.with.overflow.i64(i64 %a, i64 %b) nounwind
     48   %val = extractvalue { i64, i1 } %usub, 0
     49   %carry = extractvalue { i64, i1 } %usub, 1
     50   store i64 %val, i64 addrspace(1)* %out, align 8
     51   store i1 %carry, i1 addrspace(1)* %carryout
     52   ret void
     53 }
     54 
     55 ; FUNC-LABEL: {{^}}v_usubo_i64:
     56 ; SI: v_sub_i32
     57 ; SI: v_subb_u32
     58 define void @v_usubo_i64(i64 addrspace(1)* %out, i1 addrspace(1)* %carryout, i64 addrspace(1)* %aptr, i64 addrspace(1)* %bptr) nounwind {
     59   %a = load i64, i64 addrspace(1)* %aptr, align 4
     60   %b = load i64, i64 addrspace(1)* %bptr, align 4
     61   %usub = call { i64, i1 } @llvm.usub.with.overflow.i64(i64 %a, i64 %b) nounwind
     62   %val = extractvalue { i64, i1 } %usub, 0
     63   %carry = extractvalue { i64, i1 } %usub, 1
     64   store i64 %val, i64 addrspace(1)* %out, align 8
     65   store i1 %carry, i1 addrspace(1)* %carryout
     66   ret void
     67 }
     68