summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2019-06-10 15:08:22 +0000
committerSanjay Patel <spatel@rotateright.com>2019-06-10 15:08:22 +0000
commit07bba688895df837690e7016d6d5ae31ee34f4a1 (patch)
treeee17169937d3b229e3cb1510163aee2b9113534f
parentc573032ded9052cd2b905e4425a373ae2868385a (diff)
downloadbcm5719-llvm-07bba688895df837690e7016d6d5ae31ee34f4a1.tar.gz
bcm5719-llvm-07bba688895df837690e7016d6d5ae31ee34f4a1.zip
[InstCombine] add tests for fabs() with unordered preds; NFC
llvm-svn: 362949
-rw-r--r--llvm/test/Transforms/InstCombine/fabs.ll30
1 files changed, 30 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/fabs.ll b/llvm/test/Transforms/InstCombine/fabs.ll
index 1ee8989d3b1..afbb88713cc 100644
--- a/llvm/test/Transforms/InstCombine/fabs.ll
+++ b/llvm/test/Transforms/InstCombine/fabs.ll
@@ -275,6 +275,21 @@ define double @select_fcmp_nnan_ole_zero(double %x) {
ret double %fabs
}
+; Repeat with unordered predicate - nnan allows us to treat ordered/unordered identically.
+
+define double @select_fcmp_nnan_ule_zero(double %x) {
+; CHECK-LABEL: @select_fcmp_nnan_ule_zero(
+; CHECK-NEXT: [[LEZERO:%.*]] = fcmp ule double [[X:%.*]], 0.000000e+00
+; CHECK-NEXT: [[NEGX:%.*]] = fsub nnan double 0.000000e+00, [[X]]
+; CHECK-NEXT: [[FABS:%.*]] = select i1 [[LEZERO]], double [[NEGX]], double [[X]]
+; CHECK-NEXT: ret double [[FABS]]
+;
+ %lezero = fcmp ule double %x, 0.0
+ %negx = fsub nnan double 0.0, %x
+ %fabs = select i1 %lezero, double %negx, double %x
+ ret double %fabs
+}
+
; Negative test - wrong predicate.
define double @select_fcmp_nnan_olt_zero(double %x) {
@@ -329,6 +344,21 @@ define half @select_fcmp_nnan_ogt_negzero(half %x) {
ret half %fabs
}
+; Repeat with unordered predicate - nnan allows us to treat ordered/unordered identically.
+
+define half @select_fcmp_nnan_ugt_negzero(half %x) {
+; CHECK-LABEL: @select_fcmp_nnan_ugt_negzero(
+; CHECK-NEXT: [[GTZERO:%.*]] = fcmp ugt half [[X:%.*]], 0xH0000
+; CHECK-NEXT: [[NEGX:%.*]] = fsub nnan half 0xH0000, [[X]]
+; CHECK-NEXT: [[FABS:%.*]] = select i1 [[GTZERO]], half [[X]], half [[NEGX]]
+; CHECK-NEXT: ret half [[FABS]]
+;
+ %gtzero = fcmp ugt half %x, -0.0
+ %negx = fsub nnan half 0.0, %x
+ %fabs = select i1 %gtzero, half %x, half %negx
+ ret half %fabs
+}
+
; Negative test - wrong predicate.
define half @select_fcmp_nnan_oge_negzero(half %x) {
OpenPOWER on IntegriCloud