| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
| |
returned by BinomialCoefficient and don't try to operate with them. This
replaces the previous fix for PR2857.
llvm-svn: 57431
|
|
|
|
|
|
| |
implementing folding. Fixes PR2857.
llvm-svn: 57049
|
|
|
|
|
|
| |
of r56230, r56232, and r56246.
llvm-svn: 56247
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
- Recognize expressions like "x > -1 ? x : 0" as min/max and turn them
into expressions like "x < 0 ? 0 : x", which is easily recognizable
as a min/max operation.
- Refrain from folding expression like "y/2 < 1" to "y < 2" when the
comparison is being used as part of a min or max idiom, like
"y/2 < 1 ? 1 : y/2". In that case, the division has another use, so
folding doesn't eliminate it, and obfuscates the min/max, making it
harder to recognize as a min/max operation.
These benefit ScalarEvolution, CodeGen, and anything else that wants to
recognize integer min and max.
llvm-svn: 56246
|
|
|
|
|
|
|
| |
an if statement that guards a loop, to allow indvars to avoid smax
operations in more situations.
llvm-svn: 56232
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
its callers to emit a space character before calling it when a
space is needed.
This fixes several spurious whitespace issues in
ScalarEvolution's debug dumps. See the test changes for
examples.
This also fixes odd space-after-tab indentation in the output
for switch statements, and changes calls from being printed like
this:
call void @foo( i32 %x )
to this:
call void @foo(i32 %x)
llvm-svn: 56196
|
|
|
|
|
|
|
|
| |
continue past the first conditional branch when looking for a
relevant test. This helps it avoid using MAX expressions in
loop trip counts in more cases.
llvm-svn: 54697
|
|
|
|
| |
llvm-svn: 54545
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
version uses a new algorithm for evaluating the binomial coefficients
which is significantly more efficient for AddRecs of more than 2 terms
(see the comments in the code for details on how the algorithm works).
It also fixes some bugs: it removes the arbitrary length restriction for
AddRecs, it fixes the silent generation of incorrect code for AddRecs
which require a wide calculation width, and it fixes an issue where we
were incorrectly truncating the iteration count too far when evaluating
an AddRec expression narrower than the induction variable.
There are still a few related issues I know of: I think there's
still an issue with the SCEVExpander expansion of AddRec in terms of
the width of the induction variable used. The hack to avoid generating
too-wide integers shouldn't be necessary; instead, the callers should be
considering the cost of the expansion before expanding it (in addition
to not expanding too-wide integers, we might not want to expand
expressions that are really expensive, especially when optimizing for
size; calculating an length-17 32-bit AddRec currently generates about 250
instructions of straight-line code on X86). Also, for long 32-bit
AddRecs on X86, CodeGen really sucks at scheduling the code. I'm planning on
filing follow-up PRs for these issues.
llvm-svn: 54332
|
|
|
|
|
|
|
|
|
|
|
| |
time applying to the implicit comparison in smin expressions. The
correct way to transform an inequality into the opposite
inequality, either signed or unsigned, is with a not expression.
I looked through the SCEV code, and I don't think there are any more
occurrences of this issue.
llvm-svn: 54194
|
|
|
|
|
|
|
|
|
|
|
|
| |
SGT exit condition. Essentially, the correct way to flip an inequality
in 2's complement is the not operator, not the negation operator.
That said, the difference only affects cases involving INT_MIN.
Also, enhance the pre-test search logic to be a bit smarter about
inequalities flipped with a not operator, so it can eliminate the smax
from the iteration count for simple loops.
llvm-svn: 54184
|
|
|
|
| |
llvm-svn: 53816
|
|
|
|
|
|
|
|
|
|
| |
bail after 256-bits to avoid producing code that the backends can't handle.
Previously, we capped it at 64-bits, preferring to miscompile in those cases.
This change also reverts much of r52248 because the invariants the code was
expecting are now being met.
llvm-svn: 53812
|
|
|
|
| |
llvm-svn: 53811
|
|
|
|
|
|
| |
count.
llvm-svn: 53810
|
|
|
|
|
|
| |
I swear that didn't show up in svn diff...
llvm-svn: 53587
|
|
|
|
| |
llvm-svn: 53586
|
|
|
|
|
|
| |
started complicating many loops ('for' loops, in fact).
llvm-svn: 53508
|
|
|
|
|
|
| |
more complete version is now available from the LoopVR pass.
llvm-svn: 53269
|
|
|
|
|
|
| |
Comment the xor %x, -1 case.
llvm-svn: 53167
|
|
|
|
|
|
| |
ConstantExprs.
llvm-svn: 52615
|
|
|
|
|
|
| |
function, and make use of it in several places.
llvm-svn: 52463
|
|
|
|
|
|
|
|
| |
with code that was expecting different bit widths for different values.
Make getTruncateOrZeroExtend a method on ScalarEvolution, and use it.
llvm-svn: 52248
|
|
|
|
| |
llvm-svn: 51560
|
|
|
|
|
|
|
| |
several things that were neither in an anonymous namespace nor static
but not intended to be global.
llvm-svn: 51017
|
|
|
|
| |
llvm-svn: 50706
|
|
|
|
| |
llvm-svn: 49991
|
|
|
|
| |
llvm-svn: 49977
|
|
|
|
|
|
| |
does not work because of 0; 2>0 but -2U is also >0.
llvm-svn: 49928
|
|
|
|
|
|
|
|
| |
manually performing the comparison. This allows the special
case to work correctly even in the case where someone is
experimenting with a different comparison function :-).
llvm-svn: 49670
|
|
|
|
| |
llvm-svn: 48579
|
|
|
|
| |
llvm-svn: 48554
|
|
|
|
| |
llvm-svn: 47542
|
|
|
|
| |
llvm-svn: 47434
|
|
|
|
| |
llvm-svn: 47433
|
|
|
|
|
|
| |
annoying warnings.
llvm-svn: 47367
|
|
|
|
| |
llvm-svn: 47361
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Parse reversed smax and umax as smin and umin and express them with negative
or binary-not SCEVs (which are really just subtract under the hood).
Parse 'xor %x, -1' as (-1 - %x).
Remove dead code (ConstantInt::get always returns a ConstantInt).
Don't use getIntegerSCEV(-1, Ty). The first value is an int, then it gets
passed into a uint64_t. Instead, create the -1 directly from
ConstantInt::getAllOnesValue().
llvm-svn: 47360
|
|
|
|
| |
llvm-svn: 47062
|
|
|
|
| |
llvm-svn: 47061
|
|
|
|
|
|
|
|
|
|
| |
variable (with step 1) and m is its final value. Then, the correct trip
count is SMAX(m,n)-n. Previously, we used SMAX(0,m-n), but m-n may
overflow and can't in general be interpreted as signed.
Patch by Nick Lewycky.
llvm-svn: 47007
|
|
|
|
|
|
|
|
| |
to the RHS. This simple change allows to compute loop iteration count
for loops with condition similar to the one in the testcase (which seems
to be quite common).
llvm-svn: 46959
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
arbitrary iteration.
The patch:
1) changes SCEVSDivExpr into SCEVUDivExpr,
2) replaces PartialFact() function with BinomialCoefficient(); the
computations (essentially, the division) in BinomialCoefficient() are
performed with the apprioprate bitwidth necessary to avoid overflow;
unsigned division is used instead of the signed one.
Computations in BinomialCoefficient() require support from the code
generator for APInts. Currently, we use a hack rounding up the
neccessary bitwidth to the nearest power of 2. The hack is easy to turn
off in future.
One remaining issue: we assume the divisor of the binomial coefficient
formula can be computed accurately using 16 bits. It means we can handle
AddRecs of length up to 9. In future, we should use APInts to evaluate
the divisor.
Thanks to Nicholas for cooperation!
llvm-svn: 46955
|
|
|
|
| |
llvm-svn: 46591
|
|
|
|
| |
llvm-svn: 45485
|
|
|
|
| |
llvm-svn: 45418
|
|
|
|
|
|
|
|
| |
Reimplement the xform in Analysis/ConstantFolding.cpp where we can use
targetdata to validate that it is safe. While I'm in there, fix some const
correctness issues and generalize the interface to the "operand folder".
llvm-svn: 44817
|
|
|
|
| |
llvm-svn: 44319
|
|
|
|
| |
llvm-svn: 44295
|
|
|
|
|
|
|
| |
even though the bitcast operand did not have integer type. This fixes
PR1814.
llvm-svn: 44286
|