[TargetLowering][RISCV] Introduce isSExtCheaperThanZExt hook and implement for RISC-V
authorAlex Bradbury <asb@lowrisc.org>
Fri, 30 Nov 2018 09:56:54 +0000 (09:56 +0000)
committerAlex Bradbury <asb@lowrisc.org>
Fri, 30 Nov 2018 09:56:54 +0000 (09:56 +0000)
commite0e62e97dfddb01a6f2e32d2f951c317a7478f9a
tree258079ea1dc9509b8bfb1fc63de9a416143bbb04
parentdeaa3e2068cf14834e4063729887bb19eb4a9c2d
[TargetLowering][RISCV] Introduce isSExtCheaperThanZExt hook and implement for RISC-V

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.

Differential Revision: https://reviews.llvm.org/D52978

llvm-svn: 347977
llvm/include/llvm/CodeGen/TargetLowering.h
llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVISelLowering.h
llvm/test/CodeGen/RISCV/alu32.ll