summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/InstCombine
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2018-11-05 15:45:01 +0000
committerSanjay Patel <spatel@rotateright.com>2018-11-05 15:45:01 +0000
commit92a53eabc6deee78acce4b2e216aaffc4f71e00e (patch)
tree6cf67657bab442b344315ff1b4387d7fb9cf7929 /llvm/test/Transforms/InstCombine
parent51a91e86e1d637edd82b47dc626239ea2bd0a5f3 (diff)
downloadbcm5719-llvm-92a53eabc6deee78acce4b2e216aaffc4f71e00e.tar.gz
bcm5719-llvm-92a53eabc6deee78acce4b2e216aaffc4f71e00e.zip
[InstCombine] add/adjust tests for select with fsub identity op; NFC
llvm-svn: 346138
Diffstat (limited to 'llvm/test/Transforms/InstCombine')
-rw-r--r--llvm/test/Transforms/InstCombine/select-binop-cmp.ll26
1 files changed, 22 insertions, 4 deletions
diff --git a/llvm/test/Transforms/InstCombine/select-binop-cmp.ll b/llvm/test/Transforms/InstCombine/select-binop-cmp.ll
index edbe310269a..1604522293c 100644
--- a/llvm/test/Transforms/InstCombine/select-binop-cmp.ll
+++ b/llvm/test/Transforms/InstCombine/select-binop-cmp.ll
@@ -304,6 +304,21 @@ define float @select_fsub_fcmp(float %x, float %y, float %z) {
ret float %C
}
+; TODO: This is logically equivalent to the previous test - fcmp ignores the sign of 0.0.
+
+define float @select_fsub_fcmp_negzero(float %x, float %y, float %z) {
+; CHECK-LABEL: @select_fsub_fcmp_negzero(
+; CHECK-NEXT: [[A:%.*]] = fcmp oeq float [[X:%.*]], -0.000000e+00
+; CHECK-NEXT: [[B:%.*]] = fsub nsz float [[Z:%.*]], [[X]]
+; CHECK-NEXT: [[C:%.*]] = select i1 [[A]], float [[B]], float [[Y:%.*]]
+; CHECK-NEXT: ret float [[C]]
+;
+ %A = fcmp oeq float %x, -0.0
+ %B = fsub nsz float %z, %x
+ %C = select i1 %A, float %B, float %y
+ ret float %C
+}
+
define float @select_fdiv_fcmp(float %x, float %y, float %z) {
; CHECK-LABEL: @select_fdiv_fcmp(
; CHECK-NEXT: [[A:%.*]] = fcmp oeq float [[X:%.*]], 1.000000e+00
@@ -899,15 +914,18 @@ define float @select_fdiv_fcmp_bad_2(float %x, float %y, float %z) {
ret float %C
}
+; The transform is not valid when x = -0.0 and z = -0.0
+; (optimized code would return -0.0, but this returns +0.0).
+
define float @select_fsub_fcmp_bad(float %x, float %y, float %z) {
; CHECK-LABEL: @select_fsub_fcmp_bad(
; CHECK-NEXT: [[A:%.*]] = fcmp oeq float [[X:%.*]], 0.000000e+00
-; CHECK-NEXT: [[B:%.*]] = fsub float [[X]], [[Z:%.*]]
+; CHECK-NEXT: [[B:%.*]] = fsub float [[Z:%.*]], [[X]]
; CHECK-NEXT: [[C:%.*]] = select i1 [[A]], float [[B]], float [[Y:%.*]]
; CHECK-NEXT: ret float [[C]]
;
%A = fcmp oeq float %x, 0.0
- %B = fsub float %x, %z
+ %B = fsub float %z, %x
%C = select i1 %A, float %B, float %y
ret float %C
}
@@ -915,12 +933,12 @@ define float @select_fsub_fcmp_bad(float %x, float %y, float %z) {
define float @select_fsub_fcmp_bad_2(float %x, float %y, float %z) {
; CHECK-LABEL: @select_fsub_fcmp_bad_2(
; CHECK-NEXT: [[A:%.*]] = fcmp oeq float [[X:%.*]], 1.000000e+00
-; CHECK-NEXT: [[B:%.*]] = fsub nsz float [[X]], [[Z:%.*]]
+; CHECK-NEXT: [[B:%.*]] = fsub nsz float [[Z:%.*]], [[X]]
; CHECK-NEXT: [[C:%.*]] = select i1 [[A]], float [[B]], float [[Y:%.*]]
; CHECK-NEXT: ret float [[C]]
;
%A = fcmp oeq float %x, 1.0
- %B = fsub nsz float %x, %z
+ %B = fsub nsz float %z, %x
%C = select i1 %A, float %B, float %y
ret float %C
}
OpenPOWER on IntegriCloud