[all-commits] [llvm/llvm-project] eb1650: [LegalizeIntegerTypes] Improve ExpandIntRes_SADDSU...

Craig Topper via All-commits all-commits at lists.llvm.org
Tue Feb 23 09:54:00 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: eb165090bb063cb6b73433c30adeed6fef995108
      https://github.com/llvm/llvm-project/commit/eb165090bb063cb6b73433c30adeed6fef995108
  Author: Craig Topper <craig.topper at sifive.com>
  Date:   2021-02-23 (Tue, 23 Feb 2021)

  Changed paths:
    M llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
    M llvm/test/CodeGen/AArch64/sadd_sat_vec.ll
    M llvm/test/CodeGen/AArch64/ssub_sat_vec.ll
    M llvm/test/CodeGen/ARM/sadd_sat.ll
    M llvm/test/CodeGen/ARM/sadd_sat_plus.ll
    M llvm/test/CodeGen/ARM/ssub_sat.ll
    M llvm/test/CodeGen/ARM/ssub_sat_plus.ll
    M llvm/test/CodeGen/RISCV/sadd_sat.ll
    M llvm/test/CodeGen/RISCV/sadd_sat_plus.ll
    M llvm/test/CodeGen/RISCV/ssub_sat.ll
    M llvm/test/CodeGen/RISCV/ssub_sat_plus.ll
    M llvm/test/CodeGen/RISCV/xaluo.ll
    M llvm/test/CodeGen/Thumb2/mve-saturating-arith.ll

  Log Message:
  -----------
  [LegalizeIntegerTypes] Improve ExpandIntRes_SADDSUBO codegen on targets without SADDO/SSUBO.

This code creates 3 setccs that need to be expanded. It was
creating a sign bit test as setge X, 0 which is non-canonical.
Canonical would be setgt X, -1. This misses the special case in
IntegerExpandSetCCOperands for sign bit tests that assumes
canonical form. If we don't hit this special case we end up
with a multipart setcc instead of just checking the sign of
the high part.

To fix this I've reversed the polarity of all of the setccs to
setlt X, 0 which is canonical. The rest of the logic should
still work. This seems to produce better code on RISCV which
lacks a setgt instruction.

This probably still isn't the best code sequence we could use here.

Reviewed By: RKSimon

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




More information about the All-commits mailing list