Select 32 bit integer compare instructions for MIPS 32.
Details
Details
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
Comment Actions
On MIPS 32 integer compare instruction are implicitly zero extended, meaning bitwise instructions (generated by legalizer) are superfluous. Where would be the best place to eliminate superfluous extends, perhaps upcoming prelegalize combiner ?
Comment Actions
We currently don't have a good place for them but a pre/post-legalize combiner is where we expect them to end up. In this case, a post-legalize combiner that can use known-bits would probably be easiest since you'll have:
%2:_(s32) = G_ICMP intpred(ne), %0(s32), %1 %3:_(s32) = G_AND %2(s32), i32 1 $v0 = COPY %3(s32)
and can use the known-bits of G_ICMP to fold away the G_AND
lib/Target/Mips/MipsInstructionSelector.cpp | ||
---|---|---|
276 ↗ | (On Diff #163334) | I have a minor comment - I personally like using the MachineIRBuilder here as it takes slightly less code to write the above. Something like the following is cleaner IMO MachineIRBuilder B(I); for (const struct Instr &Instruction : Instructions) { auto MIB = B.buildInstr(Instruction.Opcode, Instruction.Def, Instruction.LHS); if (...) {} if (!MIB.constrainAllUses(TII, TRI, RBI)) return false; } ... |