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

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 11 15:04:48 PDT 2017


spatel 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.
----------------
majnemer wrote:
> 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;
Ah, ok. If we go that route, we could just have this return a bool, then the caller can return the proper value. Let me write that up.


https://reviews.llvm.org/D37713





More information about the llvm-commits mailing list