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
      4 
      5 declare { i32, i1 } @llvm.sadd.with.overflow.i32(i32, i32) nounwind readnone
      6 declare { i64, i1 } @llvm.sadd.with.overflow.i64(i64, i64) nounwind readnone
      7 
      8 ; FUNC-LABEL: {{^}}saddo_i64_zext:
      9 define void @saddo_i64_zext(i64 addrspace(1)* %out, i64 %a, i64 %b) nounwind {
     10   %sadd = call { i64, i1 } @llvm.sadd.with.overflow.i64(i64 %a, i64 %b) nounwind
     11   %val = extractvalue { i64, i1 } %sadd, 0
     12   %carry = extractvalue { i64, i1 } %sadd, 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_saddo_i32:
     20 define void @s_saddo_i32(i32 addrspace(1)* %out, i1 addrspace(1)* %carryout, i32 %a, i32 %b) nounwind {
     21   %sadd = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %a, i32 %b) nounwind
     22   %val = extractvalue { i32, i1 } %sadd, 0
     23   %carry = extractvalue { i32, i1 } %sadd, 1
     24   store i32 %val, i32 addrspace(1)* %out, align 4
     25   store i1 %carry, i1 addrspace(1)* %carryout
     26   ret void
     27 }
     28 
     29 ; FUNC-LABEL: {{^}}v_saddo_i32:
     30 define void @v_saddo_i32(i32 addrspace(1)* %out, i1 addrspace(1)* %carryout, i32 addrspace(1)* %aptr, i32 addrspace(1)* %bptr) nounwind {
     31   %a = load i32, i32 addrspace(1)* %aptr, align 4
     32   %b = load i32, i32 addrspace(1)* %bptr, align 4
     33   %sadd = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %a, i32 %b) nounwind
     34   %val = extractvalue { i32, i1 } %sadd, 0
     35   %carry = extractvalue { i32, i1 } %sadd, 1
     36   store i32 %val, i32 addrspace(1)* %out, align 4
     37   store i1 %carry, i1 addrspace(1)* %carryout
     38   ret void
     39 }
     40 
     41 ; FUNC-LABEL: {{^}}s_saddo_i64:
     42 define void @s_saddo_i64(i64 addrspace(1)* %out, i1 addrspace(1)* %carryout, i64 %a, i64 %b) nounwind {
     43   %sadd = call { i64, i1 } @llvm.sadd.with.overflow.i64(i64 %a, i64 %b) nounwind
     44   %val = extractvalue { i64, i1 } %sadd, 0
     45   %carry = extractvalue { i64, i1 } %sadd, 1
     46   store i64 %val, i64 addrspace(1)* %out, align 8
     47   store i1 %carry, i1 addrspace(1)* %carryout
     48   ret void
     49 }
     50 
     51 ; FUNC-LABEL: {{^}}v_saddo_i64:
     52 ; SI: v_add_i32
     53 ; SI: v_addc_u32
     54 define void @v_saddo_i64(i64 addrspace(1)* %out, i1 addrspace(1)* %carryout, i64 addrspace(1)* %aptr, i64 addrspace(1)* %bptr) nounwind {
     55   %a = load i64, i64 addrspace(1)* %aptr, align 4
     56   %b = load i64, i64 addrspace(1)* %bptr, align 4
     57   %sadd = call { i64, i1 } @llvm.sadd.with.overflow.i64(i64 %a, i64 %b) nounwind
     58   %val = extractvalue { i64, i1 } %sadd, 0
     59   %carry = extractvalue { i64, i1 } %sadd, 1
     60   store i64 %val, i64 addrspace(1)* %out, align 8
     61   store i1 %carry, i1 addrspace(1)* %carryout
     62   ret void
     63 }
     64