[PATCH] D152278: [SCEV] Compute SCEV for ashr(add(shl(x, n), c), m) instr triplet

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 23 14:17:46 PDT 2023


efriedma added a comment.

The revised logic makes sense.



================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:7907
+            if (ShlAmt > AShrAmt)
+              AddTruncateExpr = getTruncateExpr(ShlOp0SCEV, TruncTy);
+            else
----------------
Instead of checking `if (ShlAmt > AShrAmt)` here, can you just unconditionally do `AddTruncateExpr = getTruncateExpr(ShlOp0SCEV, TruncTy);`, then add an `if (L->getOpcode() != Instruction::Shl)` check to the equal shift amount case?

Or better, just unify the `ShlAmt > AShrAmt` and `ShlAmt == AShrAmt` cases; the logic for the `ShlAmt > AShrAmt` case should just work for the `ShlAmt == AShrAmt` case (it ends up multiplying by a constant 1, which simplifies to exactly the same thing as the existing `ShlAmt == AShrAmt` code).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152278



More information about the llvm-commits mailing list