[all-commits] [llvm/llvm-project] 50302f: [SelectionDAG][RISCV] Use isSExtCheaperThanZExt to...

Craig Topper via All-commits all-commits at lists.llvm.org
Mon Jul 19 09:25:45 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 50302feb1d2cce4a9fee38621cc7596b3c66ff02
      https://github.com/llvm/llvm-project/commit/50302feb1d2cce4a9fee38621cc7596b3c66ff02
  Author: Craig Topper <craig.topper at sifive.com>
  Date:   2021-07-19 (Mon, 19 Jul 2021)

  Changed paths:
    M llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
    M llvm/lib/Target/RISCV/RISCVISelLowering.cpp
    M llvm/test/CodeGen/RISCV/alu32.ll
    M llvm/test/CodeGen/RISCV/rv64zbb-zbp.ll
    M llvm/test/CodeGen/RISCV/xaluo.ll

  Log Message:
  -----------
  [SelectionDAG][RISCV] Use isSExtCheaperThanZExt to control whether sext or zext is used for constant folding any_extend.

RISCV would prefer a sign extended constant since that works better
with our constant materialization. We have an existing TLI hook we
use to control sign extension of setcc operands in type legalization.
That hook happens to do the right check we need here, but might be
straying from its original purpose. With only RISCV defining this
hook in tree, I wasn't sure if it was worth adding another hook
with identical behavior.

This is an alternative to D105785 where I tried to handle this in
the RISCV backend by not creating ANY_EXTENDs in some places.

Reviewed By: frasercrmck

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




More information about the All-commits mailing list