There is a transform that may replace lshr (x+1), 1 with lshr x, 1 in case
if it can prove that the result will be the same. However the initial instruction
might have an exact flag set, and it now should be dropped unless we prove
that it may hold. Incorrectly set exact attribute may then produce poison.
Details
Details
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
Comment Actions
lgtm
lib/Transforms/Utils/SimplifyIndVar.cpp | ||
---|---|---|
147 ↗ | (On Diff #168941) | I'd give this a less generic name, like IsTransformedUDivExact or something like that. |
test/Transforms/IndVarSimplify/drop-exact.ll | ||
8 ↗ | (On Diff #168941) | Are there existing tests demonstrating that we do keep exact when legal? If not, would be nice to add one. |
test/Transforms/IndVarSimplify/drop-exact.ll | ||
---|---|---|
8 ↗ | (On Diff #168941) | I tried playing with that, and I noticed that cases like %tmp21 = add nsw i32 %tmp17, 0 (for which that would have been legal to keep it) get optimized away earlier by other parts of IndVars, so this instruction doesn't live long enough. I will study whether or not it is possible to come here with something like this at all, and if not, I will just remove the check and drop exact unconditionally. |