This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Lower BUILD_VECTOR to RISCVISD::VID_VL if it is floating-point type.
ClosedPublic

Authored by HanKuanChen on Sep 12 2022, 5:51 AM.

Diff Detail

Event Timeline

HanKuanChen created this revision.Sep 12 2022, 5:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 12 2022, 5:51 AM
HanKuanChen requested review of this revision.Sep 12 2022, 5:51 AM
reames added a subscriber: reames.Sep 12 2022, 11:39 AM

High level question - why approach this as checking to see if the float is representable as an integer instead of just using the bit-pattern of the float? Using the bit-pattern would seem to match the vid sequence with a large base offset. If so, we could either emit the base as a constant, or leverage the float to int conversion if within the sequence is in the representable range.

High level question - why approach this as checking to see if the float is representable as an integer instead of just using the bit-pattern of the float? Using the bit-pattern would seem to match the vid sequence with a large base offset. If so, we could either emit the base as a constant, or leverage the float to int conversion if within the sequence is in the representable range.

I didn't follow this. Doesn't normalization of the mantissa make the exponents varied so they wouldn't be linear?

llvm/test/CodeGen/RISCV/rvv/vle_vid-vfwcvt.ll
1 ↗(On Diff #459430)

The title of this test says vfwcvt, but there are no vfwcvt instructions generated.

High level question - why approach this as checking to see if the float is representable as an integer instead of just using the bit-pattern of the float? Using the bit-pattern would seem to match the vid sequence with a large base offset. If so, we could either emit the base as a constant, or leverage the float to int conversion if within the sequence is in the representable range.

I didn't follow this. Doesn't normalization of the mantissa make the exponents varied so they wouldn't be linear?

It might be this is the answer to my question. Is there a range of float values where the step is non-constant as integer, but constant as a float?

1.0 = 0x3f800000
2.0 = 0x40000000
3.0 = 0x40400000

The delta here is 0x00400000. At least in this range, using a step of 0x00400000 and base of 0x3f800000 would seem to give the right result.

craig.topper added a comment.EditedSep 12 2022, 12:06 PM

High level question - why approach this as checking to see if the float is representable as an integer instead of just using the bit-pattern of the float? Using the bit-pattern would seem to match the vid sequence with a large base offset. If so, we could either emit the base as a constant, or leverage the float to int conversion if within the sequence is in the representable range.

I didn't follow this. Doesn't normalization of the mantissa make the exponents varied so they wouldn't be linear?

It might be this is the answer to my question. Is there a range of float values where the step is non-constant as integer, but constant as a float?

1.0 = 0x3f800000
2.0 = 0x40000000
3.0 = 0x40400000

The delta here is 0x00400000. At least in this range, using a step of 0x00400000 and base of 0x3f800000 would seem to give the right result.

Doesn't the pattern break when you hit 5.0
4.0 = 0x40800000
5.0 = 0x40a00000 <- this is only 0x00200000 away from 4.0

High level question - why approach this as checking to see if the float is representable as an integer instead of just using the bit-pattern of the float? Using the bit-pattern would seem to match the vid sequence with a large base offset. If so, we could either emit the base as a constant, or leverage the float to int conversion if within the sequence is in the representable range.

I didn't follow this. Doesn't normalization of the mantissa make the exponents varied so they wouldn't be linear?

It might be this is the answer to my question. Is there a range of float values where the step is non-constant as integer, but constant as a float?

1.0 = 0x3f800000
2.0 = 0x40000000
3.0 = 0x40400000

The delta here is 0x00400000. At least in this range, using a step of 0x00400000 and base of 0x3f800000 would seem to give the right result.

Doesn't the pattern break when you hit 5.0
4.0 = 0x40800000
5.0 = 0x40a00000 <- this is only 0x00200000 away from 4.0

It does. Consider my question answered. :)

Does this create -0.0 when it is supposed to?

Does this create -0.0 when it is supposed to?

No. If input contain -0.0, we should skip it.

  1. Rename vle_vid-vfwcvt.ll to vle_vid-vfcvt.ll.
  1. isPosZero() is used to check +0.0. Use !isNegative() instead.

Does this create -0.0 when it is supposed to?

-0.0 will be detected by IsExact.

Does this create -0.0 when it is supposed to?

-0.0 will be detected by IsExact.

Can we have a test case for that?

Add tests for -0.0 behavior.

This revision is now accepted and ready to land.Sep 13 2022, 6:46 PM
This revision was landed with ongoing or failed builds.Sep 13 2022, 6:50 PM
This revision was automatically updated to reflect the committed changes.
craig.topper reopened this revision.Sep 23 2022, 6:45 PM
This revision is now accepted and ready to land.Sep 23 2022, 6:45 PM
  1. Fix Invalid rounding mode found.
  2. Refactor and add getExactInteger.
craig.topper requested changes to this revision.Sep 27 2022, 3:24 PM

Moving to Request Changes to cancel approval. Need to re-review.

This revision now requires changes to proceed.Sep 27 2022, 3:24 PM
This revision is now accepted and ready to land.Sep 27 2022, 3:26 PM