1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instcombine -S | FileCheck %s
4 ; Check that we skip transformations if the attribute unsafe-fp-math
7 define float @mysqrt(float %x, float %y) #0 {
8 ; CHECK-LABEL: @mysqrt(
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]]
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)
26 declare float @llvm.sqrt.f32(float) #1
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.
33 define 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]]
38 %c = fmul fast double %a, %a
39 %e = call fast double @sqrtf(double %c) readnone
43 declare double @sqrtf(double) readnone ; This is not the 'sqrt' you're looking for.