Home | History | Annotate | Download | only in AMDGPU
      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 | FileCheck -check-prefix=EG -check-prefix=FUNC %s
      4 
      5 declare { i32, i1 } @llvm.uadd.with.overflow.i32(i32, i32) nounwind readnone
      6 declare { i64, i1 } @llvm.uadd.with.overflow.i64(i64, i64) nounwind readnone
      7 
      8 ; FUNC-LABEL: {{^}}uaddo_i64_zext:
      9 ; SI: add
     10 ; SI: addc
     11 ; SI: addc
     12 
     13 ; EG: ADDC_UINT
     14 ; EG: ADDC_UINT
     15 define void @uaddo_i64_zext(i64 addrspace(1)* %out, i64 %a, i64 %b) nounwind {
     16   %uadd = call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 %a, i64 %b) nounwind
     17   %val = extractvalue { i64, i1 } %uadd, 0
     18   %carry = extractvalue { i64, i1 } %uadd, 1
     19   %ext = zext i1 %carry to i64
     20   %add2 = add i64 %val, %ext
     21   store i64 %add2, i64 addrspace(1)* %out, align 8
     22   ret void
     23 }
     24 
     25 ; FUNC-LABEL: {{^}}s_uaddo_i32:
     26 ; SI: s_add_i32
     27 
     28 ; EG: ADDC_UINT
     29 ; EG: ADD_INT
     30 define void @s_uaddo_i32(i32 addrspace(1)* %out, i1 addrspace(1)* %carryout, i32 %a, i32 %b) nounwind {
     31   %uadd = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 %a, i32 %b) nounwind
     32   %val = extractvalue { i32, i1 } %uadd, 0
     33   %carry = extractvalue { i32, i1 } %uadd, 1
     34   store i32 %val, i32 addrspace(1)* %out, align 4
     35   store i1 %carry, i1 addrspace(1)* %carryout
     36   ret void
     37 }
     38 
     39 ; FUNC-LABEL: {{^}}v_uaddo_i32:
     40 ; SI: v_add_i32
     41 
     42 ; EG: ADDC_UINT
     43 ; EG: ADD_INT
     44 define void @v_uaddo_i32(i32 addrspace(1)* %out, i1 addrspace(1)* %carryout, i32 addrspace(1)* %aptr, i32 addrspace(1)* %bptr) nounwind {
     45   %a = load i32, i32 addrspace(1)* %aptr, align 4
     46   %b = load i32, i32 addrspace(1)* %bptr, align 4
     47   %uadd = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 %a, i32 %b) nounwind
     48   %val = extractvalue { i32, i1 } %uadd, 0
     49   %carry = extractvalue { i32, i1 } %uadd, 1
     50   store i32 %val, i32 addrspace(1)* %out, align 4
     51   store i1 %carry, i1 addrspace(1)* %carryout
     52   ret void
     53 }
     54 
     55 ; FUNC-LABEL: {{^}}s_uaddo_i64:
     56 ; SI: s_add_u32
     57 ; SI: s_addc_u32
     58 
     59 ; EG: ADDC_UINT
     60 ; EG: ADD_INT
     61 define void @s_uaddo_i64(i64 addrspace(1)* %out, i1 addrspace(1)* %carryout, i64 %a, i64 %b) nounwind {
     62   %uadd = call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 %a, i64 %b) nounwind
     63   %val = extractvalue { i64, i1 } %uadd, 0
     64   %carry = extractvalue { i64, i1 } %uadd, 1
     65   store i64 %val, i64 addrspace(1)* %out, align 8
     66   store i1 %carry, i1 addrspace(1)* %carryout
     67   ret void
     68 }
     69 
     70 ; FUNC-LABEL: {{^}}v_uaddo_i64:
     71 ; SI: v_add_i32
     72 ; SI: v_addc_u32
     73 
     74 ; EG: ADDC_UINT
     75 ; EG: ADD_INT
     76 define void @v_uaddo_i64(i64 addrspace(1)* %out, i1 addrspace(1)* %carryout, i64 addrspace(1)* %aptr, i64 addrspace(1)* %bptr) nounwind {
     77   %a = load i64, i64 addrspace(1)* %aptr, align 4
     78   %b = load i64, i64 addrspace(1)* %bptr, align 4
     79   %uadd = call { i64, i1 } @llvm.uadd.with.overflow.i64(i64 %a, i64 %b) nounwind
     80   %val = extractvalue { i64, i1 } %uadd, 0
     81   %carry = extractvalue { i64, i1 } %uadd, 1
     82   store i64 %val, i64 addrspace(1)* %out, align 8
     83   store i1 %carry, i1 addrspace(1)* %carryout
     84   ret void
     85 }
     86