[PATCH] D65366: [CodeGen][SelectionDAG] More efficient code for X % C == 0 (SREM case)
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 29 15:00:25 PDT 2019
craig.topper added inline comments.
================
Comment at: llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp:4796
+ // FIXME: in DAGCombine, we don't fold `rem %X, -C` to `rem %X, C`,
+ // so we may have D=-1 here, which will be handled differently from D=1.
----------------
Would rem %X, -C -> rem %X, C even be valid for urem?
================
Comment at: llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp:5009
+ // Q = floor((2 * A) / (2^K))
+ APInt Q = (3 * A).udiv(APInt::getOneBitSet(W, K));
+
----------------
Is there a trick here or is one of these a typo? The comment says 2*A and the code says 3*A.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D65366/new/
https://reviews.llvm.org/D65366
More information about the llvm-commits
mailing list