[llvm] [Support][KnownFPClass] Generalize scaling refinement to an exponent range (PR #215094)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 15 15:38:18 PDT 2026
================
@@ -952,3 +952,161 @@ define float @ret_fmul__not_inf__fsub_floor_pat_wrong_floor_val(float nofpclass(
%mul = fmul float %x, %y.sub.floor.y
ret float %mul
}
+
+; The same bound applies when the other operand is a constant.
+define float @ret_fmul__not_inf__fsub_floor_pat_const(float %y) {
+; CHECK-LABEL: define nofpclass(inf) float @ret_fmul__not_inf__fsub_floor_pat_const(
+; CHECK-SAME: float [[Y:%.*]]) #[[ATTR0]] {
+; CHECK-NEXT: [[FLOOR_Y:%.*]] = call float @llvm.floor.f32(float [[Y]]) #[[ATTR5]]
+; CHECK-NEXT: [[Y_SUB_FLOOR_Y:%.*]] = fsub float [[Y]], [[FLOOR_Y]]
+; CHECK-NEXT: [[MUL:%.*]] = fmul float [[Y_SUB_FLOOR_Y]], 3.000000e+00
+; CHECK-NEXT: ret float [[MUL]]
+;
+ %floor.y = call float @llvm.floor.f32(float %y)
+ %y.sub.floor.y = fsub float %y, %floor.y
+ %mul = fmul float %y.sub.floor.y, 3.0
+ ret float %mul
+}
+
+; Multiplying by a constant of magnitude >= 1 cannot underflow.
+define float @ret_fmul_nozerosub_const_1_5(float nofpclass(zero sub) %x) {
+; CHECK-LABEL: define nofpclass(zero sub) float @ret_fmul_nozerosub_const_1_5(
+; CHECK-SAME: float nofpclass(zero sub) [[X:%.*]]) #[[ATTR0]] {
+; CHECK-NEXT: [[MUL:%.*]] = fmul float [[X]], 1.500000e+00
+; CHECK-NEXT: ret float [[MUL]]
+;
+ %mul = fmul float %x, 1.5
+ ret float %mul
+}
+
+; Negative test, 0.75 is less than one.
+define float @ret_fmul_nozerosub_const_0_75(float nofpclass(zero sub) %x) {
+; CHECK-LABEL: define float @ret_fmul_nozerosub_const_0_75(
+; CHECK-SAME: float nofpclass(zero sub) [[X:%.*]]) #[[ATTR0]] {
----------------
ZERICO2005 wrote:
Actually, maybe we can deal with the rounding-mode improvements in a future PR. I haven't seen any correctness issues with regards to the rounding in this PR currently.
https://github.com/llvm/llvm-project/pull/215094
More information about the llvm-commits
mailing list