[PATCH] D75804: [InstCombine] Fix known bits handling in SimplifyDemandedUseBits
    Nikita Popov via Phabricator via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Sat Mar  7 05:07:04 PST 2020
    
    
  
nikic marked 4 inline comments as done.
nikic added a comment.
Some comments on the intrinsics code, as it did some weird things before...
================
Comment at: lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp:719
-
-        // TODO: Could compute known zero/one bits based on the input.
         break;
----------------
Despite what the comment says, this was already computing known bits, because the "break" falls through to the call below.
================
Comment at: lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp:752
+        KnownBitsComputed = true;
         break;
       }
----------------
While known bits were computed explicitly here, this break would still fall through to the known bits call below, and thus recompute the result from scratch.
================
Comment at: lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp:781
+        KnownBitsComputed = true;
+        break;
       }
----------------
This `return nullptr` skipped the bit of code for returning a constant integer below.
================
Comment at: lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp:790
+
+    if (!KnownBitsComputed)
+      computeKnownBits(V, Known, Depth, CxtI);
----------------
To avoid the three issues mentioned above, I'm now explicitly tracking whether known bits were computed or not for the call.
Repository:
  rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75804/new/
https://reviews.llvm.org/D75804
    
    
More information about the llvm-commits
mailing list