[PATCH] D136582: [InstCombine] fold `sub + and` pattern with specific const value

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 3 11:48:13 PDT 2022


spatel added a comment.

I still think this is a very specific/narrow transform, but if this is important to optimize, then I won't hold it up. The code seems correct. 
See inline comments for a few nits.



================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp:2045
+    // C - ((C3 -nuw X) & C2) --> (C - (C2 & C3)) + (X & C2) when:
+    // (C3 - (C2 & C3) + 1) is pow2
+    // ((C2 + C3) & ((C2 & C3) - 1)) == ((C2 & C3) - 1)
----------------
Should this be:
  // (C3 - (C2 & C3) - 1) is pow2  


================
Comment at: llvm/test/Transforms/InstCombine/sub.ll:2232
 
 ; TODO:
 ; C - ((C3 - X) & C2) --> (C - (C2 & C3)) + (X & C2) when:
----------------
Remove TODO comment


================
Comment at: llvm/test/Transforms/InstCombine/sub.ll:2249
 
 ; TODO:
 ; C - ((C3 -nuw X) & C2) --> (C - (C2 & C3)) + (X & C2) when:
----------------
Remove TODO comment


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136582/new/

https://reviews.llvm.org/D136582



More information about the llvm-commits mailing list