This is a follow-up for the patch rL335020. When we replace compares against
trunc with compares against wide IV, we can also replace signed predicates with
unsigned where it is legal.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
lib/Transforms/Utils/SimplifyIndVar.cpp | ||
---|---|---|
558 ↗ | (On Diff #153474) | That name seems misleading. It's not checking if they match, it's checking if the higest bit is zero for both. Did you mean to add a check for both being negative as well? The comments below seem to indicate so. |
lib/Transforms/Utils/SimplifyIndVar.cpp | ||
---|---|---|
558 ↗ | (On Diff #153474) | Yes, actually in the initial version it also checked negative, but then I realized that for negative values zext(trunc(x)) is never equal to x, so in practice this case will never fire. I will change the naming here. |
563 ↗ | (On Diff #153474) | It is the simplest way to avoid something like if (Cond1 || (!Cond2 && Cond3 && Cond4)) which is harder to understand. |
lib/Transforms/Utils/SimplifyIndVar.cpp | ||
---|---|---|
558 ↗ | (On Diff #153474) | It doesn't, I'll merge it with the next one. |
LGTM.
lib/Transforms/Utils/SimplifyIndVar.cpp | ||
---|---|---|
563 ↗ | (On Diff #153474) | Actually, I was wondering if it should be a freestanding function, but thinking about it now it seems like a good idea to define it where it's used. It's acting like a nested function in that sense, so I think this is fine. Thanks. |