[PATCH] Add an instcombine rule to optimize max(~a, ~b) to ~min(a, b) when profitable

Sanjoy Das sanjoy at playingwithpointers.com
Mon Feb 23 00:45:49 PST 2015


================
Comment at: lib/Transforms/InstCombine/InstCombineInternal.h:85
@@ +84,3 @@
+/// This happens in cases where the ~ can be eliminated.  If WillInvertAllUses
+/// is true, work under the assumption that the caller intends remove all uses
+/// of V and only keep uses of ~V.
----------------
majnemer wrote:
> I think you are missing a "to" between "intends" and "remove".
Yup, will fix.

================
Comment at: lib/Transforms/InstCombine/InstCombineInternal.h:88
@@ +87,3 @@
+///
+static inline bool IsFreeToInvert(Value *V, bool WillInvertAllUses) {
+  // ~(~(X)) -> X.
----------------
majnemer wrote:
> Is `WillInvertAllUses` ever different from `V->hasOneUse()`?  If not, I think it would be nicer to have this function not take the extra argument and just compute the predicate locally.
The new uses of `IsFreeToInvert` (in InstCombineSelect) have `WillInvertAllUses` as `V->hasNUses(2)`.

http://reviews.llvm.org/D7821

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list