[all-commits] [llvm/llvm-project] beb786: [X86] Add DAG combine for negation of CMOV absolut...

Craig Topper via All-commits all-commits at lists.llvm.org
Sat Oct 16 13:36:21 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: beb7862db520541fea429f27733e1993d254d76f
      https://github.com/llvm/llvm-project/commit/beb7862db520541fea429f27733e1993d254d76f
  Author: Craig Topper <craig.topper at sifive.com>
  Date:   2021-10-16 (Sat, 16 Oct 2021)

  Changed paths:
    M llvm/lib/Target/X86/X86ISelLowering.cpp
    M llvm/test/CodeGen/X86/neg-abs.ll

  Log Message:
  -----------
  [X86] Add DAG combine for negation of CMOV absolute value pattern.

This patch detects the absolute value pattern on the RHS of a
subtract. If we find it we swap the CMOV true/false values and
replace the subtract with an ADD.

There may be a more generic way to do this, but I'm not sure.
Targets that don't have legal or custom ISD::ABS use a generic
expand in DAG combiner already when it sees (neg (abs(x))). I
haven't checked what happens if the neg is a more general subtract.

Fixes PR50991 for X86.

Reviewed By: RKSimon, spatel

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




More information about the All-commits mailing list