- Make alias: (slli.uw x, 0) -> (zexti32 x).
- Use (zexti32 x) instead of (zext.w x) to simplify building the instruction sequence of immediate materialisation.
Details
- Reviewers
asb luismarques craig.topper jrtc27
Diff Detail
Unit Tests
Time | Test | |
---|---|---|
110 ms | x64 debian > LLVM.CodeGen/Thumb2::mve-blockplacement.ll |
Event Timeline
According to the spec of the B extension, (slli.uw x, 0) can fully replace the (zext.w x).
Using slli.uw can simpify the logic, which reduce an extra else branch in several places of the RISCV backend.
Is the compiler simplicity worth making the assembly harder to read since it won't print zext.w anymore?
The immediate materialisation already become more tricky with SHxADD/BCLRI/BSETI/SLLIUW, most assembly sequances are not obvious, so is it necessary to keep immediate materialisation assembly readable ?
I'm not arguing the readability of the whole immediate materialization itself. That you have to be able to read like any other instructions. My concern is that this is the only time the compiler will emit a slli.uw with a zero shift amount and there's no alias for it. It might be surprising the first time someone sees it.
According to the spec of the B extension, "zext.w" has already been aliased to "add.uw x, zero", so how about making a new alias like "zext32 x" to "slli.uw t, 0" ?
I have added alias (slli.uw x, 0) -> (zexti32 x), not sure the name is proper. But I think (slli.uw x, 0) should have an alias.
Don’t make up your own non-standard aliases; I get annoyed when binutils does the same and we have to copy them
Is there a way to append a comment after the machine instruction when calling BuildMI ? Could it be better to be slli.uw a0, a0, 0 ; zero extend i32 to i64 ?