This is an archive of the discontinued LLVM Phabricator instance.

[NVPTX] SHL.64 $r, 31 cannot be converted to a mulwide.s32
ClosedPublic

Authored by slydiman on Aug 23 2022, 4:30 PM.

Details

Summary

In order to convert to mulwide.s32, we compute the 2nd operand as MulWide.32 $r, (1 << 31).
(1 << 31) is interpreted as a negative number, and is not equivalent to the original instruction.
The code int64_t r = (int64_t)a << 31; incorrectly compiled to mul.wide.s32 %rd7, %r1, -2147483648;

Diff Detail

Event Timeline

slydiman created this revision.Aug 23 2022, 4:30 PM
slydiman requested review of this revision.Aug 23 2022, 4:30 PM
tra added a comment.Aug 23 2022, 5:05 PM

Good catch.

llvm/lib/Target/NVPTX/NVPTXInstrInfo.td
733–734

Now that we're not just checking whether the constant fits in 5 bits, the constraint needs a new name.
IntConst_0_30 ?

739–740

ditto.

slydiman updated this revision to Diff 455023.Aug 23 2022, 5:15 PM
slydiman marked 2 inline comments as done.
jchlanda accepted this revision.Aug 23 2022, 11:10 PM
This revision is now accepted and ready to land.Aug 23 2022, 11:10 PM
This revision was landed with ongoing or failed builds.Aug 24 2022, 2:40 AM
This revision was automatically updated to reflect the committed changes.