| 1 |
; Simple bit of IR to mimic CUDA's libdevice. We want to be |
| 2 |
; able to link with it and we need to make sure all __nvvm_reflect |
| 3 |
; calls are eliminated by the time PTX has been produced. |
| 4 |
|
| 5 |
target triple = "nvptx-unknown-cuda" |
| 6 |
|
| 7 |
declare i32 @__nvvm_reflect(ptr) |
| 8 |
|
| 9 |
@"$str" = private addrspace(1) constant [8 x i8] c"USE_MUL\00" |
| 10 |
|
| 11 |
define void @unused_subfunc(float %a) { |
| 12 |
ret void |
| 13 |
} |
| 14 |
|
| 15 |
define void @used_subfunc(float %a) { |
| 16 |
ret void |
| 17 |
} |
| 18 |
|
| 19 |
define float @_Z17device_mul_or_addff(float %a, float %b) { |
| 20 |
%reflect = call i32 @__nvvm_reflect(ptr addrspacecast (ptr addrspace(1) @"$str" to ptr)) |
| 21 |
%cmp = icmp ne i32 %reflect, 0 |
| 22 |
br i1 %cmp, label %use_mul, label %use_add |
| 23 |
|
| 24 |
use_mul: |
| 25 |
%ret1 = fmul float %a, %b |
| 26 |
br label %exit |
| 27 |
|
| 28 |
use_add: |
| 29 |
%ret2 = fadd float %a, %b |
| 30 |
br label %exit |
| 31 |
|
| 32 |
exit: |
| 33 |
%ret = phi float [%ret1, %use_mul], [%ret2, %use_add] |
| 34 |
|
| 35 |
call void @used_subfunc(float %ret) |
| 36 |
|
| 37 |
ret float %ret |
| 38 |
} |