Matt Arsenault | 9c47dd5 | 2016-02-11 06:02:01 +0000 | [diff] [blame] | 1 | ; RUN: llc -march=amdgcn -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 |
Tom Stellard | 86d12eb | 2014-08-01 00:32:28 +0000 | [diff] [blame] | 3 | |
| 4 | ; Test that we correctly commute a sub instruction |
Tom Stellard | 79243d9 | 2014-10-01 17:15:17 +0000 | [diff] [blame] | 5 | ; FUNC-LABEL: {{^}}sub_rev: |
Matt Arsenault | e4d0c14 | 2015-08-29 07:16:50 +0000 | [diff] [blame] | 6 | ; SI-NOT: v_sub_i32_e32 v{{[0-9]+}}, vcc, s |
| 7 | ; SI: v_subrev_i32_e32 v{{[0-9]+}}, vcc, s |
Tom Stellard | 86d12eb | 2014-08-01 00:32:28 +0000 | [diff] [blame] | 8 | |
| 9 | ; ModuleID = 'vop-shrink.ll' |
| 10 | |
| 11 | define void @sub_rev(i32 addrspace(1)* %out, <4 x i32> %sgpr, i32 %cond) { |
| 12 | entry: |
Matt Arsenault | 9c47dd5 | 2016-02-11 06:02:01 +0000 | [diff] [blame] | 13 | %vgpr = call i32 @llvm.amdgcn.workitem.id.x() #1 |
Tom Stellard | 86d12eb | 2014-08-01 00:32:28 +0000 | [diff] [blame] | 14 | %tmp = icmp eq i32 %cond, 0 |
| 15 | br i1 %tmp, label %if, label %else |
| 16 | |
| 17 | if: ; preds = %entry |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 18 | %tmp1 = getelementptr i32, i32 addrspace(1)* %out, i32 1 |
Tom Stellard | 86d12eb | 2014-08-01 00:32:28 +0000 | [diff] [blame] | 19 | %tmp2 = extractelement <4 x i32> %sgpr, i32 1 |
| 20 | store i32 %tmp2, i32 addrspace(1)* %out |
| 21 | br label %endif |
| 22 | |
| 23 | else: ; preds = %entry |
| 24 | %tmp3 = extractelement <4 x i32> %sgpr, i32 2 |
| 25 | %tmp4 = sub i32 %vgpr, %tmp3 |
| 26 | store i32 %tmp4, i32 addrspace(1)* %out |
| 27 | br label %endif |
| 28 | |
| 29 | endif: ; preds = %else, %if |
| 30 | ret void |
| 31 | } |
| 32 | |
Tom Stellard | 6407e1e | 2014-08-01 00:32:33 +0000 | [diff] [blame] | 33 | ; Test that we fold an immediate that was illegal for a 64-bit op into the |
| 34 | ; 32-bit op when we shrink it. |
| 35 | |
Tom Stellard | 79243d9 | 2014-10-01 17:15:17 +0000 | [diff] [blame] | 36 | ; FUNC-LABEL: {{^}}add_fold: |
Tom Stellard | 326d6ec | 2014-11-05 14:50:53 +0000 | [diff] [blame] | 37 | ; SI: v_add_f32_e32 v{{[0-9]+}}, 0x44800000 |
Tom Stellard | 6407e1e | 2014-08-01 00:32:33 +0000 | [diff] [blame] | 38 | define void @add_fold(float addrspace(1)* %out) { |
| 39 | entry: |
Matt Arsenault | 9c47dd5 | 2016-02-11 06:02:01 +0000 | [diff] [blame] | 40 | %tmp = call i32 @llvm.amdgcn.workitem.id.x() |
Tom Stellard | 6407e1e | 2014-08-01 00:32:33 +0000 | [diff] [blame] | 41 | %tmp1 = uitofp i32 %tmp to float |
| 42 | %tmp2 = fadd float %tmp1, 1.024000e+03 |
| 43 | store float %tmp2, float addrspace(1)* %out |
| 44 | ret void |
| 45 | } |
| 46 | |
Tom Stellard | 86d12eb | 2014-08-01 00:32:28 +0000 | [diff] [blame] | 47 | ; Function Attrs: nounwind readnone |
Matt Arsenault | 9c47dd5 | 2016-02-11 06:02:01 +0000 | [diff] [blame] | 48 | declare i32 @llvm.amdgcn.workitem.id.x() #0 |
Tom Stellard | 86d12eb | 2014-08-01 00:32:28 +0000 | [diff] [blame] | 49 | |
| 50 | attributes #0 = { nounwind readnone } |
| 51 | attributes #1 = { readnone } |