1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=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, ptr %x.addr, align 4
18 store float %y, ptr %y.addr, align 4
19 %0 = load float, ptr %x.addr, align 4
20 %1 = load float, ptr %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
28 ; The call below is to a function called "sqrtf", but its type is double.
29 ; Assume it is a user function rather than a libm function, and so don't
32 define double @fake_sqrt(double %a, double %b) {
33 ; CHECK-LABEL: @fake_sqrt(
34 ; CHECK-NEXT: [[C:%.*]] = fmul fast double [[A:%.*]], [[A]]
35 ; CHECK-NEXT: [[E:%.*]] = call fast double @sqrtf(double [[C]]) #[[ATTR1:[0-9]+]]
36 ; CHECK-NEXT: ret double [[E]]
38 %c = fmul fast double %a, %a
39 %e = call fast double @sqrtf(double %c) readnone
43 ; Standard sqrtf takes and returns float. The following is not it.
44 declare double @sqrtf(double) readnone