• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -instsimplify -S | FileCheck %s
3
4define float @fdiv_constant_fold() {
5; CHECK-LABEL: @fdiv_constant_fold(
6; CHECK-NEXT:    ret float 1.500000e+00
7;
8  %f = fdiv float 3.0, 2.0
9  ret float %f
10}
11
12define float @frem_constant_fold() {
13; CHECK-LABEL: @frem_constant_fold(
14; CHECK-NEXT:    ret float 1.000000e+00
15;
16  %f = frem float 3.0, 2.0
17  ret float %f
18}
19
20define double @fmul_fdiv_common_operand(double %x, double %y) {
21; CHECK-LABEL: @fmul_fdiv_common_operand(
22; CHECK-NEXT:    ret double %x
23;
24  %m = fmul double %x, %y
25  %d = fdiv reassoc nnan double %m, %y
26  ret double %d
27}
28
29; Negative test - the fdiv must be reassociative and not allow NaNs.
30
31define double @fmul_fdiv_common_operand_too_strict(double %x, double %y) {
32; CHECK-LABEL: @fmul_fdiv_common_operand_too_strict(
33; CHECK-NEXT:    [[M:%.*]] = fmul fast double %x, %y
34; CHECK-NEXT:    [[D:%.*]] = fdiv reassoc double [[M]], %y
35; CHECK-NEXT:    ret double [[D]]
36;
37  %m = fmul fast double %x, %y
38  %d = fdiv reassoc double %m, %y
39  ret double %d
40}
41
42; Commute the fmul operands. Use a vector type to verify that works too.
43
44define <2 x float> @fmul_fdiv_common_operand_commute_vec(<2 x float> %x, <2 x float> %y) {
45; CHECK-LABEL: @fmul_fdiv_common_operand_commute_vec(
46; CHECK-NEXT:    ret <2 x float> %x
47;
48  %m = fmul <2 x float> %y, %x
49  %d = fdiv fast <2 x float> %m, %y
50  ret <2 x float> %d
51}
52
53