DAGTypeLegalizer::PromoteSetCCOperands currently prefers to zero-extend operands when it is able to do so. For some targets this is more expensive than a sign-extension, which is also a valid choice. Introduce the isSExtCheaperThanZExt hook and use it in the new SExtOrZExtPromotedInteger helper. On RISC-V, we prefer sign-extension for FromTy == MVT::i32 and ToTy == MVT::i64, as it can be performed using a single instruction.
Details
Details
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/Target/RISCV/RISCVISelLowering.cpp | ||
---|---|---|
274 ↗ | (On Diff #168635) | Should if (!Subtarget.is64Bit()) return false; be added here? i64 shouldn't make it this far on 32 bit but is it better to be explicit? |
Comment Actions
Makes sense.
lib/CodeGen/SelectionDAG/LegalizeTypes.h | ||
---|---|---|
284 ↗ | (On Diff #168635) | This probably needs a doc-comment explaining that for a given subtarget and type, the choice of either sign-extension or zero-extension is consistent. |