summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorJames Molloy <james.molloy@arm.com>2015-07-10 12:52:00 +0000
committerJames Molloy <james.molloy@arm.com>2015-07-10 12:52:00 +0000
commit88eb535b2d3ca7f26dd27d7d2b9372c81a9398af (patch)
tree758c6949afc74a3f6a2c21907b95c228ba5d1e0d /llvm/test
parent5655fb320c407f206e17d47b9bdd6a302f6abfaf (diff)
downloadbcm5719-llvm-88eb535b2d3ca7f26dd27d7d2b9372c81a9398af.tar.gz
bcm5719-llvm-88eb535b2d3ca7f26dd27d7d2b9372c81a9398af.zip
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. llvm-svn: 241901
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Bitcode/fcmp-fast.ll23
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/test/Bitcode/fcmp-fast.ll b/llvm/test/Bitcode/fcmp-fast.ll
new file mode 100644
index 00000000000..126e3652e3a
--- /dev/null
+++ b/llvm/test/Bitcode/fcmp-fast.ll
@@ -0,0 +1,23 @@
+; 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
+}
OpenPOWER on IntegriCloud