diff options
author | Dan Gohman <gohman@apple.com> | 2010-04-22 23:14:21 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-04-22 23:14:21 +0000 |
commit | fff6c5332f748d477e6ad0bd9b60b49ae867ab42 (patch) | |
tree | bac8c13349fd6ba176a4c6e5e07f76038c90880c /lib/AsmParser/LLParser.cpp | |
parent | 60915146f4d35e12f10dcdaa155596fac79184da (diff) |
Add an initial description of a new concept: trap values, and change
the definition of the nsw and nuw flags to make use of it.
nsw was introduced to help optimizers answer yes to the following:
// Can we change i from i32 to i64 to eliminate the cast inside the loop?
for (int i = 0; i < n; ++i) A[i] *= 0.1;
// Can we assume that this loop will eventually terminate?
for (int i = 0; i <= n; ++i) A[i] *= 0.1;
In its current form, it isn't truly sufficient for either.
In the first case, if the increment overflows, it'll still have some
valid i32 value; sign-extending it will produce a value which is 33
homogeneous sign bits trailed by 31 independent undef bits. If i is
promoted to i64, it won't have those same values when it reaches that
point. (The compiler could recover here by reasoning about how i is
used by the load, but that's a lot more complicated and isn't always
possible.)
In the second case, there is no value for i which will be greater than
n, so having the increment return undef on overflow doesn't help.
Trap values are a formalization of some existing concepts that we have
about LLVM IR, and give the optimizers a better basis for answering yes
to both questions above.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102140 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AsmParser/LLParser.cpp')
0 files changed, 0 insertions, 0 deletions