[llvm-dev] [SCEV] Mul/UDiv folding (original) (raw)
Sanjoy Das via llvm-dev llvm-dev at lists.llvm.org
Thu Sep 7 14:29:43 PDT 2017
- Previous message: [llvm-dev] [SCEV] Mul/UDiv folding
- Next message: [llvm-dev] [RFC] mir-canon: A new tool for canonicalizing MIR for cleaner diffing.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi Alexandre,
On Wed, Sep 6, 2017 at 7:44 AM, Alexandre Isoard via llvm-dev <llvm-dev at lists.llvm.org> wrote:
I was looking into the expression folding strategies of SCEV and found out that we don't fold multiplication and divisions:
define void @test12(i32) { entry: %1 = udiv i32 %0, 123 %2 = mul i32 %1, 123 %3 = udiv i32 %2, 123 %4 = mul i32 %3, 123 ret void } Will give: %4 = mul i32 %3, 123 --> (123 * ((123 * (%0 /u 123)) /u 123)) U: [0,-36) S: [0,-36) Is there a specific reason for that, or can I add a folding rule? Maybe the problem is that division can round off some lsb, and multiplication can wrap around some msb, and therefore we can't easily simplify those. But even adding "exact" on udiv and "nuw nsw" on mul does
SCEV does not have an internal representation for exact UDiv, so it can only apply local rules, like in ScalarEvolution::getUDivExactExpr. To fix this you could either add a bit on SCEVUDivExpr that tracks exactness and add another peephole rule to getMulExpr.
-- Sanjoy
not help.
Best regard. -- Alexandre Isoard
LLVM Developers mailing list llvm-dev at lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
- Previous message: [llvm-dev] [SCEV] Mul/UDiv folding
- Next message: [llvm-dev] [RFC] mir-canon: A new tool for canonicalizing MIR for cleaner diffing.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]