Some compressed instructions match against negative values; store
immediates as a signed value such that these patterns will now match
the intended instructions.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Context for this patch: it's needed for CompressPats for bitmanip - since one of the compressed instructions should match against -1
I was thinking about making it clearer why this cast is necessary. The first thought was obviously to add a comment to explain (similar to the comment in your review description). But maybe there's an argument for adding a small helper? Although it would literally just be doing a cast, it's name and description should make it much clearer what is going on. I don't feel super strongly about that approach though - so do speak up if you disagree!
Actually solve the underlying problem.
Contrary to my original description, it is not TableGen that stores immediates as unsigned values, but the OpData structure. We are implicitly casting all immediates from signed to unsigned values. By correcting the type and removing that implicit cast, no explicit cast is needed later on.
To clarify, we were not missing in compressed instructions before, this change is for the future compressed instructions to be added, confirmed? Otherwise I need to check why we missed it with the fuzzer.
Yes, this only became a thing because one of the bitmanip proposed/wishlist compressed instructions wants to match against -1, all the currently ratified instructions either match immediate 0 or greater, so this wouldn't have come up before.