summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/InstCombine
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2020-01-10 11:32:55 -0500
committerSanjay Patel <spatel@rotateright.com>2020-01-10 12:02:43 -0500
commit26cdaeb1f05ba140011a43ef1ea8a37d3cf416d9 (patch)
tree14435b143317370def61e531b6160d4f13261988 /llvm/test/Transforms/InstCombine
parent0b032d7ba7157b62cd0d39f8d2dc0b0efa57a710 (diff)
downloadbcm5719-llvm-26cdaeb1f05ba140011a43ef1ea8a37d3cf416d9.tar.gz
bcm5719-llvm-26cdaeb1f05ba140011a43ef1ea8a37d3cf416d9.zip
[InstCombine] add tests for fsub; NFC
Conflicting/missing canonicalizations are visible in PR44509: https://bugs.llvm.org/show_bug.cgi?id=44509
Diffstat (limited to 'llvm/test/Transforms/InstCombine')
-rw-r--r--llvm/test/Transforms/InstCombine/fsub.ll135
1 files changed, 135 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/fsub.ll b/llvm/test/Transforms/InstCombine/fsub.ll
index 80582cf2b73..f2266dd1770 100644
--- a/llvm/test/Transforms/InstCombine/fsub.ll
+++ b/llvm/test/Transforms/InstCombine/fsub.ll
@@ -641,3 +641,138 @@ define float @fsub_fmul_fneg2_extra_use3(float %x, float %y, float %z) {
%r = fsub float %z, %mul
ret float %r
}
+
+define float @fsub_fsub(float %x, float %y, float %z) {
+; CHECK-LABEL: @fsub_fsub(
+; CHECK-NEXT: [[XY:%.*]] = fsub float [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[XYZ:%.*]] = fsub float [[XY]], [[Z:%.*]]
+; CHECK-NEXT: ret float [[XYZ]]
+;
+ %xy = fsub float %x, %y
+ %xyz = fsub float %xy, %z
+ ret float %xyz
+}
+
+define float @fsub_fsub_nsz(float %x, float %y, float %z) {
+; CHECK-LABEL: @fsub_fsub_nsz(
+; CHECK-NEXT: [[XY:%.*]] = fsub float [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[XYZ:%.*]] = fsub nsz float [[XY]], [[Z:%.*]]
+; CHECK-NEXT: ret float [[XYZ]]
+;
+ %xy = fsub float %x, %y
+ %xyz = fsub nsz float %xy, %z
+ ret float %xyz
+}
+
+define float @fsub_fsub_reassoc(float %x, float %y, float %z) {
+; CHECK-LABEL: @fsub_fsub_reassoc(
+; CHECK-NEXT: [[XY:%.*]] = fsub float [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[XYZ:%.*]] = fsub reassoc float [[XY]], [[Z:%.*]]
+; CHECK-NEXT: ret float [[XYZ]]
+;
+ %xy = fsub float %x, %y
+ %xyz = fsub reassoc float %xy, %z
+ ret float %xyz
+}
+
+define float @fsub_fsub_nsz_reassoc(float %x, float %y, float %z) {
+; CHECK-LABEL: @fsub_fsub_nsz_reassoc(
+; CHECK-NEXT: [[XY:%.*]] = fsub float [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[XYZ:%.*]] = fsub reassoc nsz float [[XY]], [[Z:%.*]]
+; CHECK-NEXT: ret float [[XYZ]]
+;
+ %xy = fsub float %x, %y
+ %xyz = fsub nsz reassoc float %xy, %z
+ ret float %xyz
+}
+
+define <2 x double> @fsub_fsub_fast_vec(<2 x double> %x, <2 x double> %y, <2 x double> %z) {
+; CHECK-LABEL: @fsub_fsub_fast_vec(
+; CHECK-NEXT: [[XY:%.*]] = fsub fast <2 x double> [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[XYZ:%.*]] = fsub fast <2 x double> [[XY]], [[Z:%.*]]
+; CHECK-NEXT: ret <2 x double> [[XYZ]]
+;
+ %xy = fsub fast <2 x double> %x, %y
+ %xyz = fsub fast reassoc <2 x double> %xy, %z
+ ret <2 x double> %xyz
+}
+
+define float @fsub_fsub_nsz_reassoc_extra_use(float %x, float %y, float %z) {
+; CHECK-LABEL: @fsub_fsub_nsz_reassoc_extra_use(
+; CHECK-NEXT: [[XY:%.*]] = fsub float [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: call void @use(float [[XY]])
+; CHECK-NEXT: [[XYZ:%.*]] = fsub reassoc nsz float [[XY]], [[Z:%.*]]
+; CHECK-NEXT: ret float [[XYZ]]
+;
+ %xy = fsub float %x, %y
+ call void @use(float %xy)
+ %xyz = fsub nsz reassoc float %xy, %z
+ ret float %xyz
+}
+
+define float @fneg_fsub(float %x, float %y) {
+; CHECK-LABEL: @fneg_fsub(
+; CHECK-NEXT: [[NEGX:%.*]] = fneg float [[X:%.*]]
+; CHECK-NEXT: [[SUB:%.*]] = fsub float [[NEGX]], [[Y:%.*]]
+; CHECK-NEXT: ret float [[SUB]]
+;
+ %negx = fneg float %x
+ %sub = fsub float %negx, %y
+ ret float %sub
+}
+
+define float @fneg_fsub_nsz(float %x, float %y) {
+; CHECK-LABEL: @fneg_fsub_nsz(
+; CHECK-NEXT: [[NEGX:%.*]] = fneg float [[X:%.*]]
+; CHECK-NEXT: [[SUB:%.*]] = fsub nsz float [[NEGX]], [[Y:%.*]]
+; CHECK-NEXT: ret float [[SUB]]
+;
+ %negx = fneg float %x
+ %sub = fsub nsz float %negx, %y
+ ret float %sub
+}
+
+define float @fake_fneg_fsub_fast(float %x, float %y) {
+; CHECK-LABEL: @fake_fneg_fsub_fast(
+; CHECK-NEXT: [[NEGX:%.*]] = fsub float -0.000000e+00, [[X:%.*]]
+; CHECK-NEXT: [[SUB:%.*]] = fsub fast float [[NEGX]], [[Y:%.*]]
+; CHECK-NEXT: ret float [[SUB]]
+;
+ %negx = fsub float -0.0, %x
+ %sub = fsub fast float %negx, %y
+ ret float %sub
+}
+
+define float @fake_fneg_fsub_fast_extra_use(float %x, float %y) {
+; CHECK-LABEL: @fake_fneg_fsub_fast_extra_use(
+; CHECK-NEXT: [[NEGX:%.*]] = fsub float -0.000000e+00, [[X:%.*]]
+; CHECK-NEXT: call void @use(float [[NEGX]])
+; CHECK-NEXT: [[SUB:%.*]] = fsub fast float [[NEGX]], [[Y:%.*]]
+; CHECK-NEXT: ret float [[SUB]]
+;
+ %negx = fsub float -0.0, %x
+ call void @use(float %negx)
+ %sub = fsub fast float %negx, %y
+ ret float %sub
+}
+
+define <2 x float> @fake_fneg_fsub_vec(<2 x float> %x, <2 x float> %y) {
+; CHECK-LABEL: @fake_fneg_fsub_vec(
+; CHECK-NEXT: [[NEGX:%.*]] = fsub <2 x float> <float -0.000000e+00, float -0.000000e+00>, [[X:%.*]]
+; CHECK-NEXT: [[SUB:%.*]] = fsub nsz <2 x float> [[NEGX]], [[Y:%.*]]
+; CHECK-NEXT: ret <2 x float> [[SUB]]
+;
+ %negx = fsub <2 x float> <float -0.0, float -0.0>, %x
+ %sub = fsub nsz <2 x float> %negx, %y
+ ret <2 x float> %sub
+}
+
+define float @fneg_fsub_constant(float %x) {
+; CHECK-LABEL: @fneg_fsub_constant(
+; CHECK-NEXT: [[SUB:%.*]] = fsub nsz float -4.200000e+01, [[X:%.*]]
+; CHECK-NEXT: ret float [[SUB]]
+;
+ %negx = fneg float %x
+ %sub = fsub nsz float %negx, 42.0
+ ret float %sub
+}
OpenPOWER on IntegriCloud