|
| 1 | +; RUN: llvm-reduce --abort-on-invalid-reduction --delta-passes=attributes --test FileCheck --test-arg %s --test-arg --input-file %s -o %t |
| 2 | +; RUN: FileCheck --check-prefixes=CHECK,RESULT %s < %t |
| 3 | + |
| 4 | +; Test that invalid reductions aren't produced on convergent functions |
| 5 | +; which use convergencectrl bundles |
| 6 | + |
| 7 | +; CHECK-LABEL: define float @convergent_intrinsic(float %x, float %y) |
| 8 | +; RESULT-SAME: [[CONVERGENT_ONLY:#[0-9]+]] { |
| 9 | +define float @convergent_intrinsic(float %x, float %y) #0 { |
| 10 | + %entry.token = call token @llvm.experimental.convergence.entry() |
| 11 | + %val = call float @llvm.amdgcn.readfirstlane.f32(float %x) [ "convergencectrl"(token %entry.token) ] |
| 12 | + ret float %val |
| 13 | +} |
| 14 | + |
| 15 | +; CHECK-LABEL: define float @convergent_callsite(float %x, float %y) |
| 16 | +; RESULT-SAME: [[CONVERGENT_ONLY]] { |
| 17 | +; RESULT: call float @extern.func(float %x, float %y) [[CONVERGENT_ONLY]] |
| 18 | +define float @convergent_callsite(float %x, float %y) #0 { |
| 19 | + %entry.token = call token @llvm.experimental.convergence.entry() |
| 20 | + %val = call float @extern.func(float %x, float %y) #0 [ "convergencectrl"(token %entry.token) ] |
| 21 | + ret float %val |
| 22 | +} |
| 23 | + |
| 24 | +; CHECK-LABEL: define float @convergent_declaration(float %x, float %y) |
| 25 | +; RESULT-SAME: [[CONVERGENT_ONLY]] { |
| 26 | +define float @convergent_declaration(float %x, float %y) #0 { |
| 27 | + %entry.token = call token @llvm.experimental.convergence.entry() |
| 28 | + %val = call float @convergent.extern.func(float %x, float %y) [ "convergencectrl"(token %entry.token) ] |
| 29 | + ret float %val |
| 30 | +} |
| 31 | + |
| 32 | +; CHECK-LABEL: define float @convergent_func_no_convergent_intrinsics(float %x, float %y) |
| 33 | +; RESULT-SAME: [[CONVERGENT_ONLY]] { |
| 34 | +define float @convergent_func_no_convergent_intrinsics(float %x, float %y) #0 { |
| 35 | + %val = call float @extern.func(float %x, float %y) |
| 36 | + ret float %val |
| 37 | +} |
| 38 | + |
| 39 | +; CHECK-LABEL: define float @convergent_func_no_convergent_bundles(float %x, float %y) |
| 40 | +; RESULT-SAME: [[CONVERGENT_ONLY]] { |
| 41 | +define float @convergent_func_no_convergent_bundles(float %x, float %y) #0 { |
| 42 | + %entry.token = call token @llvm.experimental.convergence.entry() |
| 43 | + %val = call float @extern.func(float %x, float %y) |
| 44 | + ret float %val |
| 45 | +} |
| 46 | + |
| 47 | +; CHECK-LABEL: declare float @convergent.extern.func(float, float) |
| 48 | +; RESULT-SAME: [[CONVERGENT_ONLY]]{{$}} |
| 49 | +declare float @convergent.extern.func(float, float) #0 |
| 50 | +declare float @extern.func(float, float) |
| 51 | +declare float @llvm.amdgcn.readfirstlane.f32(float) #1 |
| 52 | +declare token @llvm.experimental.convergence.entry() #2 |
| 53 | + |
| 54 | +; RESULT: attributes [[CONVERGENT_ONLY]] = { convergent } |
| 55 | + |
| 56 | +attributes #0 = { convergent nounwind } |
| 57 | +attributes #1 = { convergent nocallback nofree nounwind willreturn memory(none) } |
| 58 | +attributes #2 = { convergent nocallback nofree nosync nounwind willreturn memory(none) } |
0 commit comments