[all-commits] [llvm/llvm-project] d7fe2c: [InstCombine] Widen Sel width after Cmp to genera...

tianleliu via All-commits all-commits at lists.llvm.org
Tue Dec 17 17:02:32 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d7fe2cf8a2854f05812b87faf3ce0da296fc5fe1
      https://github.com/llvm/llvm-project/commit/d7fe2cf8a2854f05812b87faf3ce0da296fc5fe1
  Author: tianleliu <tianle.l.liu at intel.com>
  Date:   2024-12-18 (Wed, 18 Dec 2024)

  Changed paths:
    M llvm/lib/Analysis/ValueTracking.cpp
    M llvm/test/Transforms/InstCombine/minmax-fold.ll

  Log Message:
  -----------
  [InstCombine]  Widen Sel width after Cmp to generate Max/Min intrinsics. (#118932)

When Sel(Cmp) are in different integer type,

From: (K and N mean width, K < N; a and b are src operands.)
bN = Ext(bK)
cond = Cmp(aN, bN)
aK = Trunc aN
retK = Sel(cond, aK, bK)
To:
bN = Ext(bK)
cond = Cmp(aN, bN)
retN = Sel(cond, aN, bN)
retK = Trunc retN

Though Sel's operands width becomes larger, the benefit
of making type width in Sel the same as Cmp, is for combing
to max/min intrinsics, and also better performance for SIMD
instructions.
References of correctness: https://alive2.llvm.org/ce/z/Y4Kegm
                           https://alive2.llvm.org/ce/z/qFtjtR
Reference of generated code comparision:
                           https://gcc.godbolt.org/z/o97svGvYM
                           https://gcc.godbolt.org/z/59Ynj91ov



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