|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 |
| 2 | +; RUN: opt -mtriple=amdgcn-- -passes=instcombine -S < %s | FileCheck -check-prefix=OPT %s |
| 3 | +; RUN: opt -mtriple=amdgcn-- -mattr=+wavefrontsize32 -passes=instcombine -S < %s | FileCheck -check-prefix=OPT-W32 %s |
| 4 | +; RUN: opt -mtriple=amdgcn-- -mattr=+wavefrontsize64 -passes=instcombine -S < %s | FileCheck -check-prefix=OPT-W64 %s |
| 5 | +; RUN: opt -mtriple=amdgcn-- -mcpu=tonga -passes=instcombine -S < %s | FileCheck -check-prefix=OPT-W64 %s |
| 6 | +; RUN: opt -mtriple=amdgcn-- -mcpu=gfx1010 -mattr=+wavefrontsize32 -passes=instcombine -S < %s | FileCheck -check-prefix=OPT-W32 %s |
| 7 | +; RUN: opt -mtriple=amdgcn-- -mcpu=gfx1010 -mattr=+wavefrontsize64 -passes=instcombine -S < %s | FileCheck -check-prefix=OPT-W64 %s |
| 8 | +; RUN: opt -mtriple=amdgcn-- -mcpu=gfx1100 -mattr=+wavefrontsize32 -passes=instcombine -S < %s | FileCheck -check-prefix=OPT-W32 %s |
| 9 | +; RUN: opt -mtriple=amdgcn-- -mcpu=gfx1100 -mattr=+wavefrontsize64 -passes=instcombine -S < %s | FileCheck -check-prefix=OPT-W64 %s |
| 10 | + |
| 11 | +define amdgpu_kernel void @fold_wavefrontsize(ptr addrspace(1) nocapture %arg) { |
| 12 | +; OPT-LABEL: define amdgpu_kernel void @fold_wavefrontsize( |
| 13 | +; OPT-SAME: ptr addrspace(1) nocapture [[ARG:%.*]]) { |
| 14 | +; OPT-NEXT: [[BB:.*:]] |
| 15 | +; OPT-NEXT: [[TMP:%.*]] = tail call i32 @llvm.amdgcn.wavefrontsize() #[[ATTR1:[0-9]+]] |
| 16 | +; OPT-NEXT: store i32 [[TMP]], ptr addrspace(1) [[ARG]], align 4 |
| 17 | +; OPT-NEXT: ret void |
| 18 | +; |
| 19 | +; OPT-W32-LABEL: define amdgpu_kernel void @fold_wavefrontsize( |
| 20 | +; OPT-W32-SAME: ptr addrspace(1) nocapture [[ARG:%.*]]) #[[ATTR0:[0-9]+]] { |
| 21 | +; OPT-W32-NEXT: [[BB:.*:]] |
| 22 | +; OPT-W32-NEXT: store i32 32, ptr addrspace(1) [[ARG]], align 4 |
| 23 | +; OPT-W32-NEXT: ret void |
| 24 | +; |
| 25 | +; OPT-W64-LABEL: define amdgpu_kernel void @fold_wavefrontsize( |
| 26 | +; OPT-W64-SAME: ptr addrspace(1) nocapture [[ARG:%.*]]) #[[ATTR0:[0-9]+]] { |
| 27 | +; OPT-W64-NEXT: [[BB:.*:]] |
| 28 | +; OPT-W64-NEXT: store i32 64, ptr addrspace(1) [[ARG]], align 4 |
| 29 | +; OPT-W64-NEXT: ret void |
| 30 | +; |
| 31 | +bb: |
| 32 | + %tmp = tail call i32 @llvm.amdgcn.wavefrontsize() #0 |
| 33 | + store i32 %tmp, ptr addrspace(1) %arg, align 4 |
| 34 | + ret void |
| 35 | +} |
| 36 | + |
| 37 | +define amdgpu_kernel void @fold_and_optimize_wavefrontsize(ptr addrspace(1) nocapture %arg) { |
| 38 | +; OPT-LABEL: define amdgpu_kernel void @fold_and_optimize_wavefrontsize( |
| 39 | +; OPT-SAME: ptr addrspace(1) nocapture [[ARG:%.*]]) { |
| 40 | +; OPT-NEXT: [[BB:.*:]] |
| 41 | +; OPT-NEXT: [[TMP:%.*]] = tail call i32 @llvm.amdgcn.wavefrontsize() #[[ATTR1]] |
| 42 | +; OPT-NEXT: [[TMP1:%.*]] = icmp ugt i32 [[TMP]], 32 |
| 43 | +; OPT-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i32 2, i32 1 |
| 44 | +; OPT-NEXT: store i32 [[TMP2]], ptr addrspace(1) [[ARG]], align 4 |
| 45 | +; OPT-NEXT: ret void |
| 46 | +; |
| 47 | +; OPT-W32-LABEL: define amdgpu_kernel void @fold_and_optimize_wavefrontsize( |
| 48 | +; OPT-W32-SAME: ptr addrspace(1) nocapture [[ARG:%.*]]) #[[ATTR0]] { |
| 49 | +; OPT-W32-NEXT: [[BB:.*:]] |
| 50 | +; OPT-W32-NEXT: store i32 1, ptr addrspace(1) [[ARG]], align 4 |
| 51 | +; OPT-W32-NEXT: ret void |
| 52 | +; |
| 53 | +; OPT-W64-LABEL: define amdgpu_kernel void @fold_and_optimize_wavefrontsize( |
| 54 | +; OPT-W64-SAME: ptr addrspace(1) nocapture [[ARG:%.*]]) #[[ATTR0]] { |
| 55 | +; OPT-W64-NEXT: [[BB:.*:]] |
| 56 | +; OPT-W64-NEXT: store i32 2, ptr addrspace(1) [[ARG]], align 4 |
| 57 | +; OPT-W64-NEXT: ret void |
| 58 | +; |
| 59 | +bb: |
| 60 | + %tmp = tail call i32 @llvm.amdgcn.wavefrontsize() #0 |
| 61 | + %tmp1 = icmp ugt i32 %tmp, 32 |
| 62 | + %tmp2 = select i1 %tmp1, i32 2, i32 1 |
| 63 | + store i32 %tmp2, ptr addrspace(1) %arg |
| 64 | + ret void |
| 65 | +} |
| 66 | + |
| 67 | +define amdgpu_kernel void @fold_and_optimize_if_wavefrontsize(ptr addrspace(1) nocapture %arg) { |
| 68 | +; OPT-LABEL: define amdgpu_kernel void @fold_and_optimize_if_wavefrontsize( |
| 69 | +; OPT-SAME: ptr addrspace(1) nocapture [[ARG:%.*]]) { |
| 70 | +; OPT-NEXT: [[BB:.*:]] |
| 71 | +; OPT-NEXT: [[TMP:%.*]] = tail call i32 @llvm.amdgcn.wavefrontsize() #[[ATTR1]] |
| 72 | +; OPT-NEXT: [[TMP1:%.*]] = icmp ugt i32 [[TMP]], 32 |
| 73 | +; OPT-NEXT: br i1 [[TMP1]], label %[[BB2:.*]], label %[[BB3:.*]] |
| 74 | +; OPT: [[BB2]]: |
| 75 | +; OPT-NEXT: store i32 1, ptr addrspace(1) [[ARG]], align 4 |
| 76 | +; OPT-NEXT: br label %[[BB3]] |
| 77 | +; OPT: [[BB3]]: |
| 78 | +; OPT-NEXT: ret void |
| 79 | +; |
| 80 | +; OPT-W32-LABEL: define amdgpu_kernel void @fold_and_optimize_if_wavefrontsize( |
| 81 | +; OPT-W32-SAME: ptr addrspace(1) nocapture [[ARG:%.*]]) #[[ATTR0]] { |
| 82 | +; OPT-W32-NEXT: [[BB:.*:]] |
| 83 | +; OPT-W32-NEXT: br i1 false, label %[[BB2:.*]], label %[[BB3:.*]] |
| 84 | +; OPT-W32: [[BB2]]: |
| 85 | +; OPT-W32-NEXT: br label %[[BB3]] |
| 86 | +; OPT-W32: [[BB3]]: |
| 87 | +; OPT-W32-NEXT: ret void |
| 88 | +; |
| 89 | +; OPT-W64-LABEL: define amdgpu_kernel void @fold_and_optimize_if_wavefrontsize( |
| 90 | +; OPT-W64-SAME: ptr addrspace(1) nocapture [[ARG:%.*]]) #[[ATTR0]] { |
| 91 | +; OPT-W64-NEXT: [[BB:.*:]] |
| 92 | +; OPT-W64-NEXT: br i1 true, label %[[BB2:.*]], label %[[BB3:.*]] |
| 93 | +; OPT-W64: [[BB2]]: |
| 94 | +; OPT-W64-NEXT: store i32 1, ptr addrspace(1) [[ARG]], align 4 |
| 95 | +; OPT-W64-NEXT: br label %[[BB3]] |
| 96 | +; OPT-W64: [[BB3]]: |
| 97 | +; OPT-W64-NEXT: ret void |
| 98 | +; |
| 99 | +bb: |
| 100 | + %tmp = tail call i32 @llvm.amdgcn.wavefrontsize() #0 |
| 101 | + %tmp1 = icmp ugt i32 %tmp, 32 |
| 102 | + br i1 %tmp1, label %bb2, label %bb3 |
| 103 | + |
| 104 | +bb2: ; preds = %bb |
| 105 | + store i32 1, ptr addrspace(1) %arg, align 4 |
| 106 | + br label %bb3 |
| 107 | + |
| 108 | +bb3: ; preds = %bb2, %bb |
| 109 | + ret void |
| 110 | +} |
| 111 | + |
| 112 | +declare i32 @llvm.amdgcn.wavefrontsize() #0 |
| 113 | + |
| 114 | +attributes #0 = { nounwind readnone speculatable } |
0 commit comments