1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -instcombine -S | FileCheck %s 3 4; Check that we skip transformations if the attribute unsafe-fp-math 5; is not set. 6 7define float @mysqrt(float %x, float %y) #0 { 8; CHECK-LABEL: @mysqrt( 9; CHECK-NEXT: entry: 10; CHECK-NEXT: [[MUL:%.*]] = fmul fast float [[X:%.*]], [[X]] 11; CHECK-NEXT: [[TMP0:%.*]] = call float @llvm.sqrt.f32(float [[MUL]]) 12; CHECK-NEXT: ret float [[TMP0]] 13; 14entry: 15 %x.addr = alloca float, align 4 16 %y.addr = alloca float, align 4 17 store float %x, float* %x.addr, align 4 18 store float %y, float* %y.addr, align 4 19 %0 = load float, float* %x.addr, align 4 20 %1 = load float, float* %x.addr, align 4 21 %mul = fmul fast float %0, %1 22 %2 = call float @llvm.sqrt.f32(float %mul) 23 ret float %2 24} 25 26declare float @llvm.sqrt.f32(float) #1 27 28; FIXME: 29; This is a function called "sqrtf", but its type is double. 30; Assume it is a user function rather than a libm function, 31; so don't transform it. 32 33define double @fake_sqrt(double %a, double %b) { 34; CHECK-LABEL: @fake_sqrt( 35; CHECK-NEXT: [[FABS:%.*]] = call fast double @llvm.fabs.f64(double [[A:%.*]]) 36; CHECK-NEXT: ret double [[FABS]] 37; 38 %c = fmul fast double %a, %a 39 %e = call fast double @sqrtf(double %c) readnone 40 ret double %e 41} 42 43declare double @sqrtf(double) readnone ; This is not the 'sqrt' you're looking for. 44