}
; (X*Y) * X => (X*X) * Y
+; The transform only requires 'reassoc', but test other FMF in
+; the commuted variants to make sure FMF propagates as expected.
define float @reassoc_common_operand1(float %x, float %y) {
; CHECK-LABEL: @reassoc_common_operand1(
-; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[X:%.*]], [[X]]
-; CHECK-NEXT: [[MUL2:%.*]] = fmul fast float [[TMP1]], [[Y:%.*]]
+; CHECK-NEXT: [[TMP1:%.*]] = fmul reassoc float [[X:%.*]], [[X]]
+; CHECK-NEXT: [[MUL2:%.*]] = fmul reassoc float [[TMP1]], [[Y:%.*]]
; CHECK-NEXT: ret float [[MUL2]]
;
%mul1 = fmul float %x, %y
- %mul2 = fmul fast float %mul1, %x
+ %mul2 = fmul reassoc float %mul1, %x
ret float %mul2
}
define float @reassoc_common_operand3(float %x1, float %y) {
; CHECK-LABEL: @reassoc_common_operand3(
; CHECK-NEXT: [[X:%.*]] = fdiv float [[X1:%.*]], 3.000000e+00
-; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[X]], [[X]]
-; CHECK-NEXT: [[MUL2:%.*]] = fmul fast float [[TMP1]], [[Y:%.*]]
+; CHECK-NEXT: [[TMP1:%.*]] = fmul reassoc nnan float [[X]], [[X]]
+; CHECK-NEXT: [[MUL2:%.*]] = fmul reassoc nnan float [[TMP1]], [[Y:%.*]]
; CHECK-NEXT: ret float [[MUL2]]
;
%x = fdiv float %x1, 3.0 ; thwart complexity-based canonicalization
%mul1 = fmul float %x, %y
- %mul2 = fmul fast float %x, %mul1
+ %mul2 = fmul reassoc nnan float %x, %mul1
ret float %mul2
}
define float @reassoc_common_operand4(float %x1, float %y) {
; CHECK-LABEL: @reassoc_common_operand4(
; CHECK-NEXT: [[X:%.*]] = fdiv float [[X1:%.*]], 3.000000e+00
-; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[X]], [[X]]
-; CHECK-NEXT: [[MUL2:%.*]] = fmul fast float [[TMP1]], [[Y:%.*]]
+; CHECK-NEXT: [[TMP1:%.*]] = fmul reassoc ninf float [[X]], [[X]]
+; CHECK-NEXT: [[MUL2:%.*]] = fmul reassoc ninf float [[TMP1]], [[Y:%.*]]
; CHECK-NEXT: ret float [[MUL2]]
;
%x = fdiv float %x1, 3.0 ; thwart complexity-based canonicalization
%mul1 = fmul float %y, %x
- %mul2 = fmul fast float %x, %mul1
+ %mul2 = fmul reassoc ninf float %x, %mul1
ret float %mul2
}
define float @reassoc_common_operand_multi_use(float %x, float %y) {
; CHECK-LABEL: @reassoc_common_operand_multi_use(
; CHECK-NEXT: [[MUL1:%.*]] = fmul float [[X:%.*]], [[Y:%.*]]
-; CHECK-NEXT: [[MUL2:%.*]] = fmul fast float [[MUL1]], [[X]]
+; CHECK-NEXT: [[MUL2:%.*]] = fmul reassoc float [[MUL1]], [[X]]
; CHECK-NEXT: call void @use_f32(float [[MUL1]])
; CHECK-NEXT: ret float [[MUL2]]
;
%mul1 = fmul float %x, %y
- %mul2 = fmul fast float %mul1, %x
+ %mul2 = fmul reassoc float %mul1, %x
call void @use_f32(float %mul1)
ret float %mul2
}