1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-24 05:23:45 +02:00
llvm-mirror/test/Transforms/InstCombine/no_cgscc_assert.ll
Sanjay Patel 14a74b66f7 add fast-math-flags to 'call' instructions (PR21290)
This patch adds optional fast-math-flags (the same that apply to fmul/fadd/fsub/fdiv/frem/fcmp)
to call instructions in IR. Follow-up patches would use these flags in LibCallSimplifier, add 
support to clang, and extend FMF to the DAG for calls.

Motivating example:

%y = fmul fast float %x, %x
%z = tail call float @sqrtf(float %y)

We'd like to be able to optimize sqrt(x*x) into fabs(x). We do this today using a function-wide
attribute for unsafe-math, but we really want to trigger on the instructions themselves:

%z = tail call fast float @sqrtf(float %y)

because in an LTO build it's possible that calls with fast semantics have been inlined into a
function with non-fast semantics.

The code changes and tests are based on the recent commits that added "notail":
http://reviews.llvm.org/rL252368

and added FMF to fcmp:
http://reviews.llvm.org/rL241901

Differential Revision: http://reviews.llvm.org/D14707

llvm-svn: 255555
2015-12-14 21:59:03 +00:00

20 lines
528 B
LLVM

; RUN: opt < %s -inline -instcombine -S | FileCheck %s
; PR21403: http://llvm.org/bugs/show_bug.cgi?id=21403
; When the call to sqrtf is replaced by an intrinsic call to fabs,
; it should not cause a problem in CGSCC.
define float @bar(float %f) #0 {
%mul = fmul fast float %f, %f
%call1 = call float @sqrtf(float %mul) #0
ret float %call1
; CHECK-LABEL: @bar(
; CHECK-NEXT: call fast float @llvm.fabs.f32
; CHECK-NEXT: ret float
}
declare float @sqrtf(float) #0
attributes #0 = { readnone "unsafe-fp-math"="true" }