[all-commits] [llvm/llvm-project] 79bf8c: [InstCombine] Fold select(X >s 0, 0, -X) | smax(X, ...

Wenju He via All-commits all-commits at lists.llvm.org
Sun Nov 2 15:38:43 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 79bf8c0331bc7e3655e208da7ad8aa780105ac82
      https://github.com/llvm/llvm-project/commit/79bf8c0331bc7e3655e208da7ad8aa780105ac82
  Author: Wenju He <wenju.he at intel.com>
  Date:   2025-11-03 (Mon, 03 Nov 2025)

  Changed paths:
    M clang/test/CodeGen/SystemZ/builtins-systemz-zvector.c
    M clang/test/CodeGen/SystemZ/builtins-systemz-zvector5.c
    M llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
    M llvm/test/Transforms/InstCombine/or.ll

  Log Message:
  -----------
  [InstCombine] Fold select(X >s 0, 0, -X) | smax(X, 0) to abs(X) (#165200)

The IR pattern is compiled from OpenCL code:
  __builtin_astype(x > (uchar2)(0) ? x : -x, uchar2);
where smax is created by foldSelectInstWithICmp + canonicalizeSPF.

smax could also come from direct elementwise max call:
  int c = b > (int)(0) ? (int)(0) : -b;
  int d = __builtin_elementwise_max(b, (int)(0));
  *a = c | d;

https://alive2.llvm.org/ce/z/2-brvr
https://alive2.llvm.org/ce/z/Dowjzk
https://alive2.llvm.org/ce/z/kathwZ

---------

Co-authored-by: Yingwei Zheng <dtcxzyw at qq.com>
Co-authored-by: Matt Arsenault <arsenm2 at gmail.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list