[PATCH] D147117: [SCEV] When computing trip count, only zext if necessary

Joshua Cao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 29 12:11:30 PDT 2023


caojoshua added a comment.



> First, you can probably use willNotOverflow(Opcode, LHS, RHS) here instead.

Thanks. I'll try this.

> Second, I think you're solving the wrong problem with this patch.  If "1 + zext((6 * %N) - 1)" does not simplify to "zext((6 * %N))" when truncating the constant and folding the constant produces the same answer, that seems like a SCEV folding bug, and is probably the more general fix.  This would require the same basic proof, but inside getAddExpr.  Oddly, we don't seem to have either the zext or sext case there already.

Yes, I agree this is a general fix that would be beneficial for SCEV. However, I don't think its the same problem. You recommendation would give us `zext(6 * %N)`, while my current solution gives us `6 * %N`. I would prefer my result, but in practice, it probably does not matter. If you feel this extra code is not worth it, I'll add the changes to `getAddExpr()`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147117



More information about the llvm-commits mailing list