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() #0 {
5 ; CHECK-LABEL: @fdiv_constant_fold(
6 ; CHECK-NEXT: ret float 1.500000e+00
8 %f = call float @llvm.experimental.constrained.fdiv.f32(float 3.0, float 2.0, metadata !"round.tonearest", metadata !"fpexcept.ignore") #0
13 define float @fdiv_constant_fold_strict() #0 {
14 ; CHECK-LABEL: @fdiv_constant_fold_strict(
15 ; CHECK-NEXT: ret float 1.500000e+00
17 %f = call float @llvm.experimental.constrained.fdiv.f32(float 3.0, float 2.0, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
22 define float @fdiv_constant_fold_strict2() #0 {
23 ; CHECK-LABEL: @fdiv_constant_fold_strict2(
24 ; CHECK-NEXT: [[F:%.*]] = call float @llvm.experimental.constrained.fdiv.f32(float 2.000000e+00, float 3.000000e+00, metadata !"round.tonearest", metadata !"fpexcept.strict") #[[ATTR0:[0-9]+]]
25 ; CHECK-NEXT: ret float [[F]]
27 %f = call float @llvm.experimental.constrained.fdiv.f32(float 2.0, float 3.0, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
32 define float @frem_constant_fold() #0 {
33 ; CHECK-LABEL: @frem_constant_fold(
34 ; CHECK-NEXT: ret float 1.000000e+00
36 %f = call float @llvm.experimental.constrained.frem.f32(float 3.0, float 2.0, metadata !"round.tonearest", metadata !"fpexcept.ignore") #0
40 define float @frem_constant_fold_strict() #0 {
41 ; CHECK-LABEL: @frem_constant_fold_strict(
42 ; CHECK-NEXT: ret float 1.000000e+00
44 %f = call float @llvm.experimental.constrained.frem.f32(float 3.0, float 2.0, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
48 define double @fmul_fdiv_common_operand(double %x, double %y) #0 {
49 ; CHECK-LABEL: @fmul_fdiv_common_operand(
50 ; CHECK-NEXT: [[M:%.*]] = call double @llvm.experimental.constrained.fmul.f64(double [[X:%.*]], double [[Y:%.*]], metadata !"round.tonearest", metadata !"fpexcept.ignore") #[[ATTR0]]
51 ; CHECK-NEXT: [[D:%.*]] = call reassoc nnan double @llvm.experimental.constrained.fdiv.f64(double [[M]], double [[Y]], metadata !"round.tonearest", metadata !"fpexcept.ignore") #[[ATTR0]]
52 ; CHECK-NEXT: ret double [[D]]
54 %m = call double @llvm.experimental.constrained.fmul.f64(double %x, double %y, metadata !"round.tonearest", metadata !"fpexcept.ignore") #0
55 %d = call reassoc nnan double @llvm.experimental.constrained.fdiv.f64(double %m, double %y, metadata !"round.tonearest", metadata !"fpexcept.ignore") #0
59 ; Negative test - the fdiv must be reassociative and not allow NaNs.
61 define double @fmul_fdiv_common_operand_too_strict(double %x, double %y) #0 {
62 ; CHECK-LABEL: @fmul_fdiv_common_operand_too_strict(
63 ; CHECK-NEXT: [[M:%.*]] = call fast double @llvm.experimental.constrained.fmul.f64(double [[X:%.*]], double [[Y:%.*]], metadata !"round.tonearest", metadata !"fpexcept.ignore") #[[ATTR0]]
64 ; CHECK-NEXT: [[D:%.*]] = call reassoc double @llvm.experimental.constrained.fdiv.f64(double [[M]], double [[Y]], metadata !"round.tonearest", metadata !"fpexcept.ignore") #[[ATTR0]]
65 ; CHECK-NEXT: ret double [[D]]
67 %m = call fast double @llvm.experimental.constrained.fmul.f64(double %x, double %y, metadata !"round.tonearest", metadata !"fpexcept.ignore") #0
68 %d = call reassoc double @llvm.experimental.constrained.fdiv.f64(double %m, double %y, metadata !"round.tonearest", metadata !"fpexcept.ignore") #0
72 ; Commute the fmul operands. Use a vector type to verify that works too.
74 define <2 x float> @fmul_fdiv_common_operand_commute_vec(<2 x float> %x, <2 x float> %y) #0 {
75 ; CHECK-LABEL: @fmul_fdiv_common_operand_commute_vec(
76 ; CHECK-NEXT: [[M:%.*]] = call <2 x float> @llvm.experimental.constrained.fmul.v2f32(<2 x float> [[Y:%.*]], <2 x float> [[X:%.*]], metadata !"round.tonearest", metadata !"fpexcept.ignore") #[[ATTR0]]
77 ; CHECK-NEXT: [[D:%.*]] = call fast <2 x float> @llvm.experimental.constrained.fdiv.v2f32(<2 x float> [[M]], <2 x float> [[Y]], metadata !"round.tonearest", metadata !"fpexcept.ignore") #[[ATTR0]]
78 ; CHECK-NEXT: ret <2 x float> [[D]]
80 %m = call <2 x float> @llvm.experimental.constrained.fmul.v2f32(<2 x float> %y, <2 x float> %x, metadata !"round.tonearest", metadata !"fpexcept.ignore") #0
81 %d = call fast <2 x float> @llvm.experimental.constrained.fdiv.v2f32(<2 x float> %m, <2 x float> %y, metadata !"round.tonearest", metadata !"fpexcept.ignore") #0
85 declare double @llvm.experimental.constrained.fmul.f64(double, double, metadata, metadata) #0
86 declare <2 x float> @llvm.experimental.constrained.fmul.v2f32(<2 x float>, <2 x float>, metadata, metadata) #0
88 declare float @llvm.experimental.constrained.fdiv.f32(float, float, metadata, metadata) #0
89 declare double @llvm.experimental.constrained.fdiv.f64(double, double, metadata, metadata) #0
90 declare <2 x float> @llvm.experimental.constrained.fdiv.v2f32(<2 x float>, <2 x float>, metadata, metadata) #0
92 declare float @llvm.experimental.constrained.frem.f32(float, float, metadata, metadata) #0
94 attributes #0 = { strictfp }