ret float %add
}
+define double @fmul_fdiv_factor_squared(double %x, double %y) {
+; CHECK-LABEL: @fmul_fdiv_factor_squared(
+; CHECK-NEXT: [[DIV:%.*]] = fdiv fast double [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[SQUARED:%.*]] = fmul fast double [[DIV]], [[DIV]]
+; CHECK-NEXT: ret double [[SQUARED]]
+;
+ %div = fdiv fast double %x, %y
+ %squared = fmul fast double %div, %div
+ ret double %squared
+}
+
+define double @fmul_fdivs_factor_common_denominator(double %x, double %y, double %z) {
+; CHECK-LABEL: @fmul_fdivs_factor_common_denominator(
+; CHECK-NEXT: [[DIV1:%.*]] = fdiv double [[X:%.*]], [[Z:%.*]]
+; CHECK-NEXT: [[DIV2:%.*]] = fdiv double [[Y:%.*]], [[Z]]
+; CHECK-NEXT: [[MUL:%.*]] = fmul fast double [[DIV1]], [[DIV2]]
+; CHECK-NEXT: ret double [[MUL]]
+;
+ %div1 = fdiv double %x, %z
+ %div2 = fdiv double %y, %z
+ %mul = fmul fast double %div1, %div2
+ ret double %mul
+}
+
+define double @fmul_fdivs_factor(double %x, double %y, double %z, double %w) {
+; CHECK-LABEL: @fmul_fdivs_factor(
+; CHECK-NEXT: [[DIV1:%.*]] = fdiv double [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[DIV2:%.*]] = fdiv double [[Z:%.*]], [[W:%.*]]
+; CHECK-NEXT: [[MUL:%.*]] = fmul reassoc double [[DIV1]], [[DIV2]]
+; CHECK-NEXT: ret double [[MUL]]
+;
+ %div1 = fdiv double %x, %y
+ %div2 = fdiv double %z, %w
+ %mul = fmul reassoc double %div1, %div2
+ ret double %mul
+}
+
+define double @fmul_fdiv_factor(double %x, double %y, double %z) {
+; CHECK-LABEL: @fmul_fdiv_factor(
+; CHECK-NEXT: [[DIV:%.*]] = fdiv double [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[MUL:%.*]] = fmul reassoc double [[DIV]], [[Z:%.*]]
+; CHECK-NEXT: ret double [[MUL]]
+;
+ %div = fdiv double %x, %y
+ %mul = fmul reassoc double %div, %z
+ ret double %mul
+}
+
+define double @fmul_fdiv_factor_constant1(double %x, double %y) {
+; CHECK-LABEL: @fmul_fdiv_factor_constant1(
+; CHECK-NEXT: [[DIV:%.*]] = fdiv double [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: [[MUL:%.*]] = fmul reassoc double [[DIV]], 4.200000e+01
+; CHECK-NEXT: ret double [[MUL]]
+;
+ %div = fdiv double %x, %y
+ %mul = fmul reassoc double %div, 42.0
+ ret double %mul
+}
+
+define <2 x float> @fmul_fdiv_factor_constant2(<2 x float> %x, <2 x float> %y) {
+; CHECK-LABEL: @fmul_fdiv_factor_constant2(
+; CHECK-NEXT: [[DIV:%.*]] = fdiv <2 x float> [[X:%.*]], <float 4.200000e+01, float 1.200000e+01>
+; CHECK-NEXT: [[MUL:%.*]] = fmul reassoc <2 x float> [[DIV]], [[Y:%.*]]
+; CHECK-NEXT: ret <2 x float> [[MUL]]
+;
+ %div = fdiv <2 x float> %x, <float 42.0, float 12.0>
+ %mul = fmul reassoc <2 x float> %div, %y
+ ret <2 x float> %mul
+}
+
+define float @fmul_fdiv_factor_extra_use(float %x, float %y) {
+; CHECK-LABEL: @fmul_fdiv_factor_extra_use(
+; CHECK-NEXT: [[DIV:%.*]] = fdiv float [[X:%.*]], 4.200000e+01
+; CHECK-NEXT: call void @use_f32(float [[DIV]])
+; CHECK-NEXT: [[MUL:%.*]] = fmul reassoc float [[DIV]], [[Y:%.*]]
+; CHECK-NEXT: ret float [[MUL]]
+;
+ %div = fdiv float %x, 42.0
+ call void @use_f32(float %div)
+ %mul = fmul reassoc float %div, %y
+ ret float %mul
+}