[all-commits] [llvm/llvm-project] 38ab47: [DAG] Match USUBSAT patterns through zext/trunc

Simon Pilgrim via All-commits all-commits at lists.llvm.org
Sun Feb 21 07:47:21 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 38ab47c8136d4f928cfd4babb89cb3c7ab783437
      https://github.com/llvm/llvm-project/commit/38ab47c8136d4f928cfd4babb89cb3c7ab783437
  Author: Simon Pilgrim <llvm-dev at redking.me.uk>
  Date:   2021-02-21 (Sun, 21 Feb 2021)

  Changed paths:
    M llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
    M llvm/test/CodeGen/X86/psubus.ll

  Log Message:
  -----------
  [DAG] Match USUBSAT patterns through zext/trunc

This patch handles usubsat patterns hidden through zext/trunc and uses the getTruncatedUSUBSAT helper to determine if the USUBSAT can be correctly performed in the truncated form:

zext(x) >= y ? x - trunc(y) : 0 --> usubsat(x,trunc(umin(y,SatLimit)))
zext(x) >  y ? x - trunc(y) : 0 --> usubsat(x,trunc(umin(y,SatLimit)))

Based on original examples:

void foo(unsigned short *p, int max, int n) {
    int i;
    unsigned m;
    for (i = 0; i < n; i++) {
        m = *--p;
        *p = (unsigned short)(m >= max ? m-max : 0);
    }
}

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




More information about the All-commits mailing list