[PATCH] [LSR] canonicalize Prod*(1<<C) to Prod<<C

David Majnemer david.majnemer at gmail.com
Mon Jun 15 11:55:18 PDT 2015


================
Comment at: lib/Analysis/ScalarEvolutionExpander.cpp:769-772
@@ -770,1 +768,6 @@
       if (isa<Constant>(Prod)) std::swap(Prod, W);
+      if (ConstantInt *ConstW = dyn_cast<ConstantInt>(W)) {
+        const APInt &RHS = ConstW->getValue();
+        // Canonicalize Prod*(1<<C) to Prod<<C.
+        if (RHS.isPowerOf2()) {
+          Prod = InsertBinop(Instruction::Shl, Prod,
----------------
You could write this most concisely as:
  // Canonicalize Prod*(1<<C) to Prod<<C.
  if (match(W, m_Power2()) {
    ...
  }

http://reviews.llvm.org/D10448

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






More information about the llvm-commits mailing list