45 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -passes=instcombine -S | FileCheck %s3 4; Check that we skip transformations if the attribute unsafe-fp-math5; 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 416 %y.addr = alloca float, align 417 store float %x, ptr %x.addr, align 418 store float %y, ptr %y.addr, align 419 %0 = load float, ptr %x.addr, align 420 %1 = load float, ptr %x.addr, align 421 %mul = fmul fast float %0, %122 %2 = call float @llvm.sqrt.f32(float %mul)23 ret float %224}25 26declare float @llvm.sqrt.f32(float) #127 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't30; transform it.31 32define 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]]37;38 %c = fmul fast double %a, %a39 %e = call fast double @sqrtf(double %c) readnone40 ret double %e41}42 43; Standard sqrtf takes and returns float. The following is not it.44declare double @sqrtf(double) readnone45