yuyang-ok opened PR #6015 from issue5992
to main
:
This will fix #5992 and #5993
yuyang-ok edited PR #6015 from issue5992
to main
:
This will fix #5992 and #5993
We should normalize float type when convert to int on {i8,i16}.
Becauseriscv64
has no direct instruction support it.
yuyang-ok updated PR #6015 from issue5992
to main
.
yuyang-ok edited PR #6015 from issue5992
to main
:
This will fix #5992 and #5993
We should normalize float type when convert float to int on {i8,i16}.
Becauseriscv64
has no direct instruction support it.I also changed the
rounding mode
.
<img width="929" alt="image" src="https://user-images.githubusercontent.com/96557710/224904674-f4de4893-f04a-49bc-b966-da0356e2aafc.png">
yuyang-ok edited PR #6015 from issue5992
to main
:
This will fix #5992 and #5993
We should normalize float type when convert float to int on {i8,i16}.
Becauseriscv64
has no direct instruction support it.I also changed the
rounding mode
.
<img width="929" alt="image" src="https://user-images.githubusercontent.com/96557710/224904674-f4de4893-f04a-49bc-b966-da0356e2aafc.png">
yuyang-ok edited PR #6015 from issue5992
to main
:
This will fix #5992 and #5993
We should normalize float type when convert float to int on {i8,i16}.
Becauseriscv64
has no direct instruction support it.
yuyang-ok updated PR #6015 from issue5992
to main
.
yuyang-ok edited PR #6015 from issue5992
to main
:
This will fix #5992 and #5993
We should normalize float type when convert float to int on {i8,i16}.
Becauseriscv64
has no direct instruction to support it.
yuyang-ok updated PR #6015 from issue5992
to main
.
yuyang-ok updated PR #6015 from issue5992
to main
.
yuyang-ok updated PR #6015 from issue5992
to main
.
afonso360 submitted PR review.
afonso360 submitted PR review.
afonso360 created PR review comment:
What do you think about moving this to ISLE? This seems like the type of code that would be really neatly written there.
afonso360 created PR review comment:
I think this might have been included accidentally
afonso360 created PR review comment:
Can we rename this to something like
clamp_*
? Unlike the normalize functions this one actually changes the value of the register.
yuyang-ok updated PR #6015 from issue5992
to main
.
yuyang-ok updated PR #6015 from issue5992
to main
.
yuyang-ok updated PR #6015 from issue5992
to main
.
yuyang-ok updated PR #6015 from issue5992
to main
.
afonso360 submitted PR review.
afonso360 submitted PR review.
afonso360 created PR review comment:
Looks like we can't name this
fmin
since it conflicts with the preexisting declaration for thefmin
clif instruction. I guess adding a prefix to all RISCV instruction helpers would make sense? The x86 backend hasx64_*
so we could add something likerv_*
, what do you guys think about this?If everyone agrees I don't mind doing a pass on the backend adding the helpers and making sure everything is aligned.
afonso360 created PR review comment:
I don't think we have an established coding style for isle, but we should probably try to keep it somewhat consistent. This would usually be something along these lines in the other backends:
(let ((min_value i32 (i8_i16_min_value ty is_signed)) (min_reg Reg (imm in_ty (i32_2_float_bits min_value in_ty))) (tmp Reg (fmax_ in_ty min_reg r)) (max_value i32 (i8_i16_max_value ty is_signed)) (max_reg Reg (imm in_ty (i32_2_float_bits max_value in_ty)))) (fmin_ in_ty tmp max_reg)))
afonso360 created PR review comment:
I guess I have a slight preference for having these on ISLE as well, but I'm not too sure. @jameysharp what do you think about this?
afonso360 created PR review comment:
Shouldn't the type on
fpu_rrr
be$F32
as well?
afonso360 created PR review comment:
This seems to target the whole family of
fcvt_*
instructions, but the clamp here is really only needed forfcvt_*_sat
which do the saturating conversions.
afonso360 edited PR review comment.
afonso360 submitted PR review.
afonso360 submitted PR review.
jameysharp submitted PR review.
jameysharp submitted PR review.
jameysharp created PR review comment:
This can be expressed more directly:
(rule (clamp_fcvt_from_float _ _ r _) r) (rule 1 (clamp_fcvt_from_float in_ty (fits_in_16 ty) r is_signed)
jameysharp created PR review comment:
I think a prefix like
rv_
is a good idea. But I also think it would be okay to merge this with thefmin_
/fmax_
names, and clean it up later.
jameysharp created PR review comment:
In general I agree that I'd like to do as much in ISLE as possible.
I think there are a number of tricks we can use which might clean this up, but I'm having trouble putting them together into a complete suggestion.
The pure ISLE version of this probably would return the appropriate hex-literal float for each combination of type and is_signed. I'm not sure how easy that'll be to write, understand, or maintain.
Leaving some of the work to Rust, we can factor it differently to shorten the code. With signed conversion, we can start with
i64::MAX
ori64::MIN
, thenx >> (64 - ty.bits())
, then usef32_bits(x as f32)
orf64_bits(x as f64)
. Unsigned is the same except for starting withu64::MAX
oru64::MIN
and using unsigned shifts. Since we apparently only need to clamp forfits_in_16
types (why is that though?) we can replace64
with16
in the first two steps.
yuyang-ok updated PR #6015 from issue5992
to main
.
yuyang-ok updated PR #6015 from issue5992
to main
.
afonso360 submitted PR review.
afonso360 created PR review comment:
Since we apparently only need to clamp for fits_in_16 types (why is that though?)
We have native instructions for this operation in both 32 and 64 bit variants, but for <16 we clamp the values to the maximum range supported by i8/i16 and then do the 32 bit conversion.
yuyang-ok requested jameysharp for a review on PR #6015.
yuyang-ok requested wasmtime-compiler-reviewers for a review on PR #6015.
yuyang-ok updated PR #6015.
yuyang-ok updated PR #6015.
yuyang-ok updated PR #6015.
yuyang-ok updated PR #6015.
afonso360 closed without merge PR #6015.
Last updated: Nov 22 2024 at 16:03 UTC