Matt Arsenault | ee324ff | 2017-05-17 19:25:06 +0000 | [diff] [blame] | 1 | ; RUN: llc -march=amdgcn < %s | FileCheck -check-prefixes=GCN,SI %s |
| 2 | ; RUN: llc -march=amdgcn -mcpu=tonga < %s | FileCheck -check-prefixes=GCN,VI %s |
| 3 | ; RUN: llc -march=amdgcn -mcpu=gfx900 < %s | FileCheck -check-prefixes=GCN,GFX9 %s |
Matt Arsenault | cc3c2b3 | 2014-11-14 20:08:52 +0000 | [diff] [blame] | 4 | |
Matt Arsenault | ee324ff | 2017-05-17 19:25:06 +0000 | [diff] [blame] | 5 | ; GCN-LABEL: {{^}}v_test_imax3_sgt_i32: |
| 6 | ; GCN: v_max3_i32 |
| 7 | define amdgpu_kernel void @v_test_imax3_sgt_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr, i32 addrspace(1)* %bptr, i32 addrspace(1)* %cptr) #0 { |
| 8 | %tid = call i32 @llvm.amdgcn.workitem.id.x() |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 9 | %gep0 = getelementptr i32, i32 addrspace(1)* %aptr, i32 %tid |
| 10 | %gep1 = getelementptr i32, i32 addrspace(1)* %bptr, i32 %tid |
| 11 | %gep2 = getelementptr i32, i32 addrspace(1)* %cptr, i32 %tid |
| 12 | %outgep = getelementptr i32, i32 addrspace(1)* %out, i32 %tid |
Matt Arsenault | ee324ff | 2017-05-17 19:25:06 +0000 | [diff] [blame] | 13 | %a = load i32, i32 addrspace(1)* %gep0 |
| 14 | %b = load i32, i32 addrspace(1)* %gep1 |
| 15 | %c = load i32, i32 addrspace(1)* %gep2 |
Matt Arsenault | cc3c2b3 | 2014-11-14 20:08:52 +0000 | [diff] [blame] | 16 | %icmp0 = icmp sgt i32 %a, %b |
| 17 | %i0 = select i1 %icmp0, i32 %a, i32 %b |
| 18 | %icmp1 = icmp sgt i32 %i0, %c |
| 19 | %i1 = select i1 %icmp1, i32 %i0, i32 %c |
Matt Arsenault | ee324ff | 2017-05-17 19:25:06 +0000 | [diff] [blame] | 20 | store i32 %i1, i32 addrspace(1)* %out |
Matt Arsenault | cc3c2b3 | 2014-11-14 20:08:52 +0000 | [diff] [blame] | 21 | ret void |
| 22 | } |
| 23 | |
Matt Arsenault | ee324ff | 2017-05-17 19:25:06 +0000 | [diff] [blame] | 24 | ; GCN-LABEL: {{^}}v_test_umax3_ugt_i32: |
| 25 | ; GCN: v_max3_u32 |
| 26 | define amdgpu_kernel void @v_test_umax3_ugt_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr, i32 addrspace(1)* %bptr, i32 addrspace(1)* %cptr) #0 { |
| 27 | %tid = call i32 @llvm.amdgcn.workitem.id.x() |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 28 | %gep0 = getelementptr i32, i32 addrspace(1)* %aptr, i32 %tid |
| 29 | %gep1 = getelementptr i32, i32 addrspace(1)* %bptr, i32 %tid |
| 30 | %gep2 = getelementptr i32, i32 addrspace(1)* %cptr, i32 %tid |
| 31 | %outgep = getelementptr i32, i32 addrspace(1)* %out, i32 %tid |
Matt Arsenault | ee324ff | 2017-05-17 19:25:06 +0000 | [diff] [blame] | 32 | %a = load i32, i32 addrspace(1)* %gep0 |
| 33 | %b = load i32, i32 addrspace(1)* %gep1 |
| 34 | %c = load i32, i32 addrspace(1)* %gep2 |
Matt Arsenault | cc3c2b3 | 2014-11-14 20:08:52 +0000 | [diff] [blame] | 35 | %icmp0 = icmp ugt i32 %a, %b |
| 36 | %i0 = select i1 %icmp0, i32 %a, i32 %b |
| 37 | %icmp1 = icmp ugt i32 %i0, %c |
| 38 | %i1 = select i1 %icmp1, i32 %i0, i32 %c |
Matt Arsenault | ee324ff | 2017-05-17 19:25:06 +0000 | [diff] [blame] | 39 | store i32 %i1, i32 addrspace(1)* %out |
Matt Arsenault | cc3c2b3 | 2014-11-14 20:08:52 +0000 | [diff] [blame] | 40 | ret void |
| 41 | } |
Matt Arsenault | ee324ff | 2017-05-17 19:25:06 +0000 | [diff] [blame] | 42 | |
| 43 | ; GCN-LABEL: {{^}}v_test_imax3_sgt_i16: |
| 44 | ; SI: v_max3_i32 |
| 45 | |
| 46 | ; VI: v_max_i16 |
| 47 | ; VI: v_max_i16 |
| 48 | |
| 49 | ; GFX9: v_max3_i16 |
| 50 | define amdgpu_kernel void @v_test_imax3_sgt_i16(i16 addrspace(1)* %out, i16 addrspace(1)* %aptr, i16 addrspace(1)* %bptr, i16 addrspace(1)* %cptr) #0 { |
| 51 | %tid = call i32 @llvm.amdgcn.workitem.id.x() |
| 52 | %gep0 = getelementptr i16, i16 addrspace(1)* %aptr, i32 %tid |
| 53 | %gep1 = getelementptr i16, i16 addrspace(1)* %bptr, i32 %tid |
| 54 | %gep2 = getelementptr i16, i16 addrspace(1)* %cptr, i32 %tid |
| 55 | %outgep = getelementptr i16, i16 addrspace(1)* %out, i32 %tid |
| 56 | %a = load i16, i16 addrspace(1)* %gep0 |
| 57 | %b = load i16, i16 addrspace(1)* %gep1 |
| 58 | %c = load i16, i16 addrspace(1)* %gep2 |
| 59 | %icmp0 = icmp sgt i16 %a, %b |
| 60 | %i0 = select i1 %icmp0, i16 %a, i16 %b |
| 61 | %icmp1 = icmp sgt i16 %i0, %c |
| 62 | %i1 = select i1 %icmp1, i16 %i0, i16 %c |
| 63 | store i16 %i1, i16 addrspace(1)* %out |
| 64 | ret void |
| 65 | } |
| 66 | |
| 67 | ; GCN-LABEL: {{^}}v_test_umax3_ugt_i16: |
| 68 | ; SI: v_max3_u32 |
| 69 | |
| 70 | ; VI: v_max_u16 |
| 71 | ; VI: v_max_u16 |
| 72 | |
| 73 | ; GFX9: v_max3_u16 |
| 74 | define amdgpu_kernel void @v_test_umax3_ugt_i16(i16 addrspace(1)* %out, i16 addrspace(1)* %aptr, i16 addrspace(1)* %bptr, i16 addrspace(1)* %cptr) #0 { |
| 75 | %tid = call i32 @llvm.amdgcn.workitem.id.x() |
| 76 | %gep0 = getelementptr i16, i16 addrspace(1)* %aptr, i32 %tid |
| 77 | %gep1 = getelementptr i16, i16 addrspace(1)* %bptr, i32 %tid |
| 78 | %gep2 = getelementptr i16, i16 addrspace(1)* %cptr, i32 %tid |
| 79 | %outgep = getelementptr i16, i16 addrspace(1)* %out, i32 %tid |
| 80 | %a = load i16, i16 addrspace(1)* %gep0 |
| 81 | %b = load i16, i16 addrspace(1)* %gep1 |
| 82 | %c = load i16, i16 addrspace(1)* %gep2 |
| 83 | %icmp0 = icmp ugt i16 %a, %b |
| 84 | %i0 = select i1 %icmp0, i16 %a, i16 %b |
| 85 | %icmp1 = icmp ugt i16 %i0, %c |
| 86 | %i1 = select i1 %icmp1, i16 %i0, i16 %c |
| 87 | store i16 %i1, i16 addrspace(1)* %out |
| 88 | ret void |
| 89 | } |
| 90 | |
| 91 | declare i32 @llvm.amdgcn.workitem.id.x() #1 |
| 92 | |
| 93 | attributes #0 = { nounwind } |
| 94 | attributes #1 = { nounwind readnone speculatable } |