Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
What about the arguably more common case of a = b | ((c & mask) << shamt) (when c is not known to be small enough to not require the masking) or a = b | (c & mask), where all positions in a to be overwritten by the incoming bits are known to be zero?
One of the applicable real-world scenario is RISC code generation, where a lot of ORing between a "clean" insn template and shifted/masked operands take place. One doesn't mask the bits in the template hence the optimization chance is missed.
The other cases LGTM, though.
Sorry to reply so late. Good suggestion! And a = b | ((c << shamt) & shifted_mask) seems also apply. Let me try to update the revision. Thanks!
And of course I meant "all positions in b to be overwritten ...", instead of a which is the destination. "Known bits" is the key though.
llvm/test/CodeGen/LoongArch/bstrins_d.ll | ||
---|---|---|
137 | typo: because. You can include the fix in the next revision, together with the other changes you plan to make. No need to push a new revision just for this, for your convenience (and less email clutter for everyone). | |
llvm/test/CodeGen/LoongArch/bstrins_w.ll | ||
149 | Ditto. |
The logic looks good, thanks.
I have several more real-world test cases (LoongArch and IA64 code generation) but I plan to submit them after this lands.
llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp | ||
---|---|---|
666 | nit: "in order to match" for consistency with the wording in the 6th pattern above. | |
699 | nit: "we put it here in order to match" | |
llvm/test/CodeGen/LoongArch/bstrins_d.ll | ||
176 | typo: "pattern 7" | |
llvm/test/CodeGen/LoongArch/bstrins_w.ll | ||
184 | ditto |
nit: "in order to match" for consistency with the wording in the 6th pattern above.