summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/test/Transforms')
-rw-r--r--llvm/test/Transforms/InstSimplify/fdiv.ll34
1 files changed, 34 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstSimplify/fdiv.ll b/llvm/test/Transforms/InstSimplify/fdiv.ll
index 6643afd8147..cc883cbbaf1 100644
--- a/llvm/test/Transforms/InstSimplify/fdiv.ll
+++ b/llvm/test/Transforms/InstSimplify/fdiv.ll
@@ -34,3 +34,37 @@ define double @fdiv_by_undef(double %X) {
%r = fdiv double %X, undef
ret double %r
}
+
+define double @fmul_fdiv_common_operand(double %x, double %y) {
+; CHECK-LABEL: @fmul_fdiv_common_operand(
+; CHECK-NEXT: ret double %x
+;
+ %m = fmul double %x, %y
+ %d = fdiv reassoc nnan double %m, %y
+ ret double %d
+}
+
+; Negative test - the fdiv must be reassociative and not allow NaNs.
+
+define double @fmul_fdiv_common_operand_too_strict(double %x, double %y) {
+; CHECK-LABEL: @fmul_fdiv_common_operand_too_strict(
+; CHECK-NEXT: [[M:%.*]] = fmul fast double %x, %y
+; CHECK-NEXT: [[D:%.*]] = fdiv reassoc double [[M]], %y
+; CHECK-NEXT: ret double [[D]]
+;
+ %m = fmul fast double %x, %y
+ %d = fdiv reassoc double %m, %y
+ ret double %d
+}
+
+; Commute the fmul operands. Use a vector type to verify that works too.
+
+define <2 x float> @fmul_fdiv_common_operand_commute_vec(<2 x float> %x, <2 x float> %y) {
+; CHECK-LABEL: @fmul_fdiv_common_operand_commute_vec(
+; CHECK-NEXT: ret <2 x float> %x
+;
+ %m = fmul <2 x float> %y, %x
+ %d = fdiv fast <2 x float> %m, %y
+ ret <2 x float> %d
+}
+
OpenPOWER on IntegriCloud