llvm/test/Bitcode/fcmp-fast.ll
James Molloy ee0d992b07 Add support for fast-math flags to the FCmp instruction.
FCmp behaves a lot like a floating-point binary operator in many ways,
and can benefit from fast-math information. Flags such as nsz and nnan
can affect if this fcmp (in combination with a select) can be treated
as a fminnum/fmaxnum operation.

This adds backwards-compatible bitcode support, IR parsing and writing,
LangRef changes and IRBuilder changes. I'll need to audit InstSimplify
and InstCombine in a followup to find places where flags should be
copied.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241901 91177308-0d34-0410-b5e6-96231b3b80d8
2015-07-10 12:52:00 +00:00

24 lines
690 B
LLVM

; RUN: llvm-as < %s | llvm-dis > %t0
; RUN: opt -S < %s > %t1
; RUN: diff %t0 %t1
; RUN: FileCheck < %t1 %s
; Make sure flags on fcmp instructions are serialized/deserialized properly.
define i1 @foo(float %a, float %b, double %c, double %d) {
; CHECK: %plain = fcmp ueq float %a, %b
%plain = fcmp ueq float %a, %b
; CHECK: %fast = fcmp fast olt float %a, %b
%fast = fcmp fast olt float %a, %b
; CHECK: %nsz = fcmp nsz uge float %a, %b
%nsz = fcmp nsz uge float %a, %b
; CHECK: %nnan = fcmp nnan nsz oge double %c, %d
%nnan = fcmp nnan nsz oge double %c, %d
%dce1 = or i1 %plain, %fast
%dce2 = or i1 %dce1, %nsz
%dce3 = or i1 %dce2, %nnan
ret i1 %dce3
}