1 ; RUN: opt < %s -S -nvvm-reflect -nvvm-reflect-list USE_MUL=0 -O2 | FileCheck %s --check-prefix=USE_MUL_0 2 ; RUN: opt < %s -S -nvvm-reflect -nvvm-reflect-list USE_MUL=1 -O2 | FileCheck %s --check-prefix=USE_MUL_1 3 4 @str = private addrspace(4) unnamed_addr constant [8 x i8] c"USE_MUL\00" 5 6 declare i32 @__nvvm_reflect(i8*) 7 declare i8* @llvm.nvvm.ptr.constant.to.gen.p0i8.p4i8(i8 addrspace(4)*) 8 9 define float @foo(float %a, float %b) { 10 ; USE_MUL_0: define float @foo 11 ; USE_MUL_0-NOT: call i32 @__nvvm_reflect 12 ; USE_MUL_1: define float @foo 13 ; USE_MUL_1-NOT: call i32 @__nvvm_reflect 14 %ptr = tail call i8* @llvm.nvvm.ptr.constant.to.gen.p0i8.p4i8(i8 addrspace(4)* getelementptr inbounds ([8 x i8] addrspace(4)* @str, i32 0, i32 0)) 15 %reflect = tail call i32 @__nvvm_reflect(i8* %ptr) 16 %cmp = icmp ugt i32 %reflect, 0 17 br i1 %cmp, label %use_mul, label %use_add 18 19 use_mul: 20 ; USE_MUL_1: fmul float %a, %b 21 ; USE_MUL_0-NOT: fadd float %a, %b 22 %ret1 = fmul float %a, %b 23 br label %exit 24 25 use_add: 26 ; USE_MUL_0: fadd float %a, %b 27 ; USE_MUL_1-NOT: fmul float %a, %b 28 %ret2 = fadd float %a, %b 29 br label %exit 30 31 exit: 32 %ret = phi float [%ret1, %use_mul], [%ret2, %use_add] 33 ret float %ret 34 } 35