[PATCH] D156811: [InstCombine] Fold `select` of `srem` and conditional add

Antonio Frighetto via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 3 10:37:45 PDT 2023


antoniofrighetto added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp:2616
+        IC.isKnownToBeAPowerOfTwo(Remainder, /*OrZero*/ true) &&
+        (TrueIfSigned ? (FalseVal == RemRes) : (TrueVal == RemRes))))
+    return nullptr;
----------------
craig.topper wrote:
> This line `match(TrueVal, m_Add(m_Value(RemRes), m_Value(Remainder)))` is also incorrect when `TrueIfSigned` is false. Which is why I suggested swapping the True and False value.
Right, ifdef'ing out the call to `foldSelectInstWithICmp` exhibits this clearly. Should be good now.


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

https://reviews.llvm.org/D156811



More information about the llvm-commits mailing list