1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instsimplify -S | FileCheck %s
4 define float @fdiv_constant_fold() {
5 ; CHECK-LABEL: @fdiv_constant_fold(
6 ; CHECK-NEXT: ret float 1.500000e+00
8 %f = fdiv float 3.0, 2.0
12 define float @frem_constant_fold() {
13 ; CHECK-LABEL: @frem_constant_fold(
14 ; CHECK-NEXT: ret float 1.000000e+00
16 %f = frem float 3.0, 2.0
20 define double @fmul_fdiv_common_operand(double %x, double %y) {
21 ; CHECK-LABEL: @fmul_fdiv_common_operand(
22 ; CHECK-NEXT: ret double %x
24 %m = fmul double %x, %y
25 %d = fdiv reassoc nnan double %m, %y
29 ; Negative test - the fdiv must be reassociative and not allow NaNs.
31 define 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]]
37 %m = fmul fast double %x, %y
38 %d = fdiv reassoc double %m, %y
42 ; Commute the fmul operands. Use a vector type to verify that works too.
44 define <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
48 %m = fmul <2 x float> %y, %x
49 %d = fdiv fast <2 x float> %m, %y