llvm-project/llvm/lib/Transforms/InstCombine
Sanjay Patel 09a136bcc6 [InstCombine] narrow min/max intrinsics with extended inputs
We can sink extends after min/max if they match and would
not change the sign-interpreted compare. The only combo
that doesn't work is zext+smin/smax because the zexts
could change a negative number into positive:
https://alive2.llvm.org/ce/z/D6sz6J

Sext+umax/umin works:

  define i32 @src(i8 %x, i8 %y) {
  %0:
    %sx = sext i8 %x to i32
    %sy = sext i8 %y to i32
    %m = umax i32 %sx, %sy
    ret i32 %m
  }
  =>
  define i32 @tgt(i8 %x, i8 %y) {
  %0:
    %m = umax i8 %x, %y
    %r = sext i8 %m to i32
    ret i32 %r
  }
  Transformation seems to be correct!
2021-01-25 07:52:50 -05:00
..
CMakeLists.txt llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
InstCombineAddSub.cpp [InstCombine] Transform (A + B) - (A & B) to A | B (PR48604) 2020-12-31 15:04:32 +01:00
InstCombineAndOrXor.cpp [InstCombine] Fold `(~x) | y` --> `~(x & (~y))` iff it is free to do so 2021-01-22 17:23:54 +03:00
InstCombineAtomicRMW.cpp Add missing namespace closure comments. NFCI. 2020-09-23 16:19:25 +01:00
InstCombineCalls.cpp [InstCombine] narrow min/max intrinsics with extended inputs 2021-01-25 07:52:50 -05:00
InstCombineCasts.cpp [STLExtras] Use return type from operator* of the wrapped iter. 2021-01-10 14:41:13 +00:00
InstCombineCompares.cpp [NFC][InstCombine] Extract freelyInvertAllUsersOf() out of canonicalizeICmpPredicate() 2021-01-22 17:23:53 +03:00
InstCombineInternal.h [InstCombine] Set MadeIRChange in replaceInstUsesWith. 2021-01-23 17:52:59 +00:00
InstCombineLoadStoreAlloca.cpp [Transforms] Use llvm::append_range (NFC) 2021-01-20 21:35:54 -08:00
InstCombineMulDivRem.cpp [InstCombine] Transform abs pattern using multiplication to abs intrinsic (PR45691) 2021-01-17 17:06:14 +01:00
InstCombineNegator.cpp [Constant] Add containsPoisonElement 2021-01-06 12:10:33 +09:00
InstCombinePHI.cpp Add missing namespace closure comments. NFCI. 2020-09-23 16:19:25 +01:00
InstCombineSelect.cpp Reapply [InstCombine] Replace one-use select operand based on condition 2021-01-19 20:26:38 +01:00
InstCombineShifts.cpp [InstCombine] canonicalize sign-bit-shift of difference to ext(icmp) 2020-12-01 09:58:11 -05:00
InstCombineSimplifyDemanded.cpp [InstCombine] use poison as placeholder for undemanded elems 2020-12-28 08:58:15 +09:00
InstCombineVectorOps.cpp [InstCombine] Use is_contained (NFC) 2020-11-21 15:47:11 -08:00
InstructionCombining.cpp [InstCombine] Remove unused llvm.experimental.noalias.scope.decl 2021-01-24 13:55:50 +01:00