[PATCH] D37713: [InstSimplify] fold sdiv/srem based on compare of dividend and divisor

David Majnemer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 11 14:40:33 PDT 2017


majnemer added inline comments.


================
Comment at: lib/Analysis/InstructionSimplify.cpp:1022-1023
 
+static Value *simplifySignedDivRem(Value *X, Value *Y, const SimplifyQuery &Q,
+                                   unsigned MaxRecurse, bool IsDiv) {
+  // Recursion is always used, so bail out at once if we already hit the limit.
----------------
You could make this a little simpler by getting rid of the IsDiv flag.
The remainder side could do something like:
  if (Constant *C = dyn_cast_or_null<Constant>(simplifySignedDiv(Op0, Op1, Q, MaxRecurse)))
    if (C->isNullValue())
      return Op0;


https://reviews.llvm.org/D37713





More information about the llvm-commits mailing list