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

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 8 12:47:53 PDT 2023


nikic added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp:2618
+  // %sel = select i1 %cnd, i32 %add, i32 %rem
+  if (!(match(TrueVal, m_Add(m_Value(RemRes), m_Value(Remainder))) &&
+        match(RemRes, m_SRem(m_Value(Op), m_Specific(Remainder))) &&
----------------
I think this fails to handle the case where the add operands are commuted? Can't happen for constant remainder, but I don't think anything would guarantee the remainder is on the RHS if it's variable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156811



More information about the llvm-commits mailing list