[PATCH] D85092: [InstSimplify] Peephole optimization for icmp (urem X, Y), X

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 2 05:33:13 PDT 2020


lebedev.ri added a comment.

Thank you for the patch!



================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:2967
 
+  // icmp pred (urem Y, X), Y
+  if (LBO && match(LBO, m_URem(m_Specific(RHS), m_Value()))) {
----------------
This appears correct, but you also need to handle ` icmp pred Y, (urem Y, X)` case.
I know that naively one would expect it to be canonicalized by complexity sorting,
and i think said complexity sorting is a subtle evil.


================
Comment at: llvm/test/Transforms/InstSimplify/compare.ll:726
 
+define i1 @urem8(i32 %X, i32 %Y) {
+  ; CHECK-LABEL: @urem8(
----------------
I think these could be `i8`, to simplify the life of alive :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85092



More information about the llvm-commits mailing list