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

David Majnemer david.majnemer at gmail.com
Sun Feb 22 22:51:51 PST 2015


================
Comment at: lib/Transforms/InstCombine/InstCombineSelect.cpp:1169-1172
@@ +1168,6 @@
+
+      // Is it free to change the ICmpInst and the SelectInst using V to use ~V
+      // instead?
+      auto IsFreeToInvert = [](Value *V) {
+        if (match(V, m_Not(m_Value())))
+          return true;
----------------
Can we improve `isFreeToInvert` and just use that instead?

================
Comment at: lib/Transforms/InstCombine/InstCombineSelect.cpp:1183-1184
@@ +1182,4 @@
+              BO->getOpcode() == Instruction::Sub)
+            return isa<Constant>(BO->getOperand(0)) ||
+              isa<Constant>(BO->getOperand(1));
+
----------------
This doesn't look formatted correctly, can you please run clang-format on this?

http://reviews.llvm.org/D7821

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






More information about the llvm-commits mailing list