[PATCH] D44266: [InstCombine] remove use restriction for min/max with not operands (PR35875)

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 5 19:01:26 PDT 2018


efriedma added a comment.

There are basically three equivalencies here: `~~a == a`, `(~a-~b)==(b-a)`, and `UMIN(~a, ~b) == ~UMAX(a, b)`. The tricky bit is turning those three equivalencies into a profitable transform.  instcombine is generally bad at this sort of transform; we don't keep track of potential transforms, so instead we usually just suppress transforms which are not immediately profitable.  So maybe we miss some transforms, but at least we aren't making the user's code worse.

So I guess these are the options:

1. Make the code worse, and hope it gets better later.  That's what this patch does, but it's not something we like to do usually; often it happens to be profitable for the particular testcase someone is looking at, but it makes the code worse in other cases.
2. Use a gigantic match for your exact testcase.  This works, but obviously isn't very general.
3. Make a new pass (or AggressiveInstCombine) which does some sort of "global" optimization (to, for example, minimize the total number of not operations in a function).


https://reviews.llvm.org/D44266





More information about the llvm-commits mailing list