[PATCH] D112573: [IndVarSimplify] Reduce nondeterministic behaviour in visitIVCast.
Max Kazantsev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 1 00:41:31 PDT 2021
mkazantsev added a comment.
If I understand your proposal correctly, you propose to replace scheme "take signedness from 1st user which is non-deterministically selected" with scheme "if at least one user of widest type is signed cast, widen as signed; otherwize widen as unsigned"?
In general, it makes sense to me and it also seems to solve the non-determinism you are describing. The only concern I have is, you use signed widening as default (and unsigned is possible under stricter conditions). On the other hand, IV tries hard to turn all `icmp`'s to unsigned predicate form, preferring unsigned as default. This creates some discord between different parts of it.
Is it possible to use unsigned widening as break-even? In terms of your patch it would be replacing
WI.IsSigned |= IsSigned;
with
WI.IsSigned &= IsSigned;
================
Comment at: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:560
+ // unspecified order of a PHI nodes' users-iterator.
+ if (WI.IsSigned != IsSigned && IsSigned)
+ WI.IsSigned = true;
----------------
Do you mean `if (!WI.IsSigned && IsSigned)` ? I guess it's an equivalent check. And it is also equivalent to unconditional
```
WI.IsSigned |= IsSigned;
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D112573/new/
https://reviews.llvm.org/D112573
More information about the llvm-commits
mailing list