[PATCH] [InstCombine] Constant comparison involving "lshr exact"

Rafael Ávila de Espíndola rafael.espindola at gmail.com
Mon Jun 2 05:42:52 PDT 2014


================
Comment at: lib/Transforms/InstCombine/InstCombineCompares.cpp:2448
@@ -2448,3 +2447,3 @@
     {
-      ConstantInt *CI2;
+      ConstantInt *CI2 = nullptr;
       if (match(Op0, m_AShr(m_ConstantInt(CI2), m_Value(A))) &&
----------------
This is not necessary, is it? match will have initialized CI2, so there is no uninitialized access.

================
Comment at: lib/Transforms/InstCombine/InstCombineCompares.cpp:2458
@@ +2457,3 @@
+    
+    // Handle the case for lhsr similar to above transformation.
+    {
----------------
Can this share code with the above case? Use a helper function if needed. It looks like it could look something like

APInt Quotient;
if (...) 
   Quotient = CI2->getValue().sdiv(CI->getValue());
else if (...)
   Quotient = CI2->getValue().udiv(CI->getValue());
else
   // no transform.

http://reviews.llvm.org/D3987






More information about the llvm-commits mailing list