[PATCH] D52177: [InstCombine] Fold ~A - Min/Max(~A, O) -> Max/Min(A, ~O) - A

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 17 10:02:44 PDT 2018


dmgreen created this revision.
dmgreen added reviewers: spatel, craig.topper.

This is an attempt to get out of a local-minimum that instcombine currently gets stuck in. We essentially combine two optimisations at once, `~a - ~b = b-a` and `min(~a, ~b) = ~max(a, b)`, only doing the transform if the result is at least neutral. This involves using IsFreeToInvert, which has been expanded a little to include selects that can be easily inverted.

This is trying to fix PR35875, using the ideas from Sanjay. It is a large improvement to one of our rgb to cmy kernels.


https://reviews.llvm.org/D52177

Files:
  lib/Transforms/InstCombine/InstCombineAddSub.cpp
  lib/Transforms/InstCombine/InstCombineInternal.h
  test/Transforms/InstCombine/max-of-nots.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52177.165778.patch
Type: text/x-patch
Size: 6488 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180917/e496cfd4/attachment.bin>


More information about the llvm-commits mailing list