Commit Graph

2039 Commits

Author SHA1 Message Date
Chris Lattner
e9100c69cb Simplify for loop, clear a per-loop map after processing each loop
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22580 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-02 02:44:31 +00:00
Chris Lattner
07cd0ff298 Add a comment
Make LSR ignore GEP's that have loop variant base values, as we currently
cannot codegen them


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22576 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-02 01:32:29 +00:00
Chris Lattner
1060e09fb2 Fix an iterator invalidation problem
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22575 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-02 00:41:11 +00:00
Chris Lattner
9cc5f42feb ConstantInt::get only works for arguments < 128.
SimplifyLibCalls probably has to be audited to make sure it does not make
this mistake elsewhere.  Also, if this code knows that the type will be
unsigned, obviously one arm of this is dead.

Reid, can you take a look into this further?


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22566 91177308-0d34-0410-b5e6-96231b3b80d8
2005-08-01 16:52:50 +00:00
Jeff Cohen
d29b6aa608 Keep tabs and trailing spaces out.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22565 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-30 18:33:25 +00:00
Jeff Cohen
cfb1d4235f Fix VC++ build problems.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22564 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-30 18:22:27 +00:00
Nate Begeman
f84d5ab5df Ack, typo
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22560 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-30 00:21:31 +00:00
Nate Begeman
1699748567 Commit a new LoopStrengthReduce pass that can use scalar evolutions and
target data to decide which loop induction variables to strength reduce
and how to do so.  This work is mostly by Chris Lattner, with tweaks by
me to get it working on some of MultiSource.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22558 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-30 00:15:07 +00:00
Nate Begeman
36f891bdf6 Break SCEVExpander out of IndVarSimplify into its own .h/.cpp file so that
other passes may use it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22557 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-30 00:12:19 +00:00
Jeff Cohen
00b16889ab Eliminate all remaining tabs and trailing spaces.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22523 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-27 06:12:32 +00:00
Chris Lattner
600d73b548 ConvertibleToGEP always returns 0, remove some old crufty code which
is actually dead because of this!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22515 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-26 16:38:28 +00:00
Chris Lattner
f9944f109c Do not let MaskedValueIsZero consider undef to be zero, for reasons
explained in the comment.

This fixes UnitTests/2003-09-18-BitFieldTest on darwin


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22483 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-20 18:49:28 +00:00
Chris Lattner
7911f03626 When transforming &A[i] < &A[j] -> i < j, make sure to perform the comparison
as a signed compare.  This patch may fix PR597, but is correct in any case.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22465 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-18 23:07:33 +00:00
Chris Lattner
b3d59701c8 Fix a problem that instcombine would hit when dealing with unreachable code.
Because the instcombine has to scan the entire function when it starts up
to begin with, we might as well do it in DFO so we can nuke unreachable code.

This fixes: Transforms/InstCombine/2005-07-07-DeadPHILoop.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22348 91177308-0d34-0410-b5e6-96231b3b80d8
2005-07-07 20:40:38 +00:00
Chris Lattner
6cfd1ebcd3 Fix PR590 and Transforms/Mem2Reg/2005-06-30-ReadBeforeWrite.ll.
The optimization for locally used allocas was not safe for allocas that
were read before they were written.  This change disables that optimization
in that case.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22318 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-30 07:29:44 +00:00
John Criswell
46b8db2ec6 Doh! Forgot to LLVMify the style.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22312 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-29 15:57:50 +00:00
John Criswell
1d231ec0b0 Basic fix for PR#591; don't convert an fprintf() to an fwrite() if there
is a mismatch in their character type pointers (i.e. fprintf() prints an
array of ubytes while fwrite() takes an array of sbytes).
We can probably do better than this (such as casting the ubyte to an
sbyte).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22310 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-29 15:03:18 +00:00
Chris Lattner
543a02704e add a debug type
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22277 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-24 16:00:46 +00:00
Andrew Lenharth
38b5807bd9 prevent va_arg from being hoisted from a loop
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22265 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-20 13:36:33 +00:00
Andrew Lenharth
94cd87f658 prevent DCE of vaarg intrinsics. This should take care of most regressions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22263 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-19 14:41:20 +00:00
Andrew Lenharth
558bc88a00 core changes for varargs
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22254 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-18 18:34:52 +00:00
Reid Spencer
134d2e4af8 Fix a problem with the strcmp optimization checking the wrong string and
not casting to the correct type.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22250 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-18 17:46:28 +00:00
Reid Spencer
4b828e6384 Clean up some uninitialized variables and missing return statements that
GCC 4.0.0 compiler (sometimes incorrectly) warns about under release build.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22249 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-18 17:37:34 +00:00
Chris Lattner
e88b7533be This is not true: (X != 13 | X < 15) -> X < 15
It is actually always true.  This fixes PR586 and
Transforms/InstCombine/2005-06-16-SetCCOrSetCCMiscompile.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22236 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-17 03:59:17 +00:00
Chris Lattner
5662503afd Don't crash when dealing with INTMIN. This fixes PR585 and
Transforms/InstCombine/2005-06-16-RangeCrash.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22234 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-17 02:05:55 +00:00
Chris Lattner
0289929c62 Don't crash on: X = phi (X, X).
This fixes PR584 and Transforms/SimplifyCFG/2005-06-16-PHICrash.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22232 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-17 01:45:53 +00:00
Chris Lattner
d7e31cfaae avoid constructing out of range shift amounts.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22230 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-17 01:29:28 +00:00
Chris Lattner
f9c775c22e Fix PR583 and testcase Transforms/InstCombine/2005-06-15-DivSelectCrash.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22227 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-16 04:55:52 +00:00
Chris Lattner
8d7089e1d5 Fix PR571, removing code that does just the WRONG thing :)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22225 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-16 03:00:08 +00:00
Chris Lattner
aa457ac2e7 Fix a bug in my previous patch. Do not get the shift amount type (which
is always ubyte, get the type being shifted).  This unbreaks espresso


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22224 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-16 01:52:07 +00:00
Chris Lattner
d286b245be Fix PR575, patch provided by John Mellor-Crummey. Thanks!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22223 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-15 22:49:30 +00:00
Chris Lattner
4bd09d70cc Fix PR582. The rewriter can move casts around, which invalidated the
BB iterator.  This fixes Transforms/IndVarsSimplify/2005-06-15-InstMoveCrash.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22221 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-15 21:29:31 +00:00
Chris Lattner
553ca52623 Do not promote globals only used by main to locals if there are constantexprs
or other uses hanging off of them.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22219 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-15 21:11:48 +00:00
Chris Lattner
e17a128a55 Fix PR577 and testcase InstCombine/2005-06-15-ShiftSetCCCrash.ll.
Do not perform undefined out of range shifts.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22217 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-15 20:53:31 +00:00
Reid Spencer
877c3e2b81 Put the hack back in that removes features, causes regressions to fail, but
allows test programs to succeed. Actual fix for this is forthcoming.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22213 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-15 18:25:30 +00:00
Reid Spencer
16b5644f04 Unbreak several InstCombine regression checks introduced by a hack to
fix the bzip2 test. A better hack is needed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22209 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-13 06:41:26 +00:00
Chris Lattner
71fae1022e Fix a 64-bit problem, passing (int)0 through ... instead of (void*)0
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22206 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-09 03:32:54 +00:00
Chris Lattner
5633cd13e2 Fix a problem on 64-bit targets where we passed (int)0 through ... instead of
(void*)0.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22205 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-09 02:59:00 +00:00
Andrew Lenharth
837be1ec35 hack to fix bzip2 (bug 571)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22192 91177308-0d34-0410-b5e6-96231b3b80d8
2005-06-04 12:43:56 +00:00
Reid Spencer
89026028d1 Make the registration hash_map static. No other module needs it. Also,
document what its for a little better.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22164 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-21 01:27:04 +00:00
Reid Spencer
0660f754df Adjust the file comment to read a little easier.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22163 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-21 00:57:44 +00:00
Reid Spencer
b82baf04ec Make sure ... arguments are casted to sbyte* where needed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22162 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-21 00:39:30 +00:00
Reid Spencer
5845623148 Add a "brief" comment for CastToCStr
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22161 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-21 00:23:23 +00:00
Chris Lattner
9375135999 Fix mismatched type problem that crashed on cases like this:
sprintf(P, "%s", X);

Where X is not an sbyte*.  This fixes the bug JohnMC reported on llvm-bugs.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22159 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-20 22:22:25 +00:00
Chris Lattner
42eb7524ef Fix Transforms/SimplifyCFG/switch-simplify-crash.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22158 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-20 22:19:54 +00:00
Chris Lattner
49fbff4568 teach the inliner about coldcc and noreturn functions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22113 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-18 04:30:33 +00:00
Reid Spencer
c3f6abdd85 Don't look for __builtin_ffs, we'll never see it from llvm-gcc and there's
not reason to include it for other front ends.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22070 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-15 21:27:34 +00:00
Reid Spencer
f74eb3fa2a Provide this optimization as well:
ffs(x) -> (x == 0 ? 0 : 1+llvm.cttz(x))


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22068 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-15 21:19:45 +00:00
Reid Spencer
c64e3e77f9 Duh .. you actually have to #include Config/config.h before you can test
for one of the values that it defines!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22058 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-15 17:20:47 +00:00
Reid Spencer
c29b13d648 Changes for ffs lib call simplification:
* Check for availability of ffsll call in configure script
* Support ffs, ffsl, and ffsll conversion to constant value if the argument
  is constant.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22027 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-14 16:42:52 +00:00
Chris Lattner
65af1abd1e Preserve calling conv when hacking on calls
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22025 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-14 12:28:32 +00:00
Chris Lattner
e43702695d preserve calling conventions when hacking on code
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22024 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-14 12:25:32 +00:00
Chris Lattner
16d0db2da8 Make sure to preserve the calling convention when changing an invoke into
a call.  This fixes Prolangs-C++/deriv2, kimwitu++, and Misc-C++/bigfib
on X86 with -enable-x86-fastcc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22023 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-14 12:21:56 +00:00
Chris Lattner
08b22ecc88 calling a function with the wrong CC is undefined, turn it into an unreachable
instruction.  This is useful for catching optimizers that don't preserve
calling conventions


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21928 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-13 07:09:09 +00:00
Chris Lattner
efd9168eae When lowering invokes to calls, amke sure to preserve the calling conv. This
fixes Ptrdist/anagram with x86 llcbeta


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21925 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-13 06:27:02 +00:00
Chris Lattner
1381dd8a6e Prefer int 0 instead of long 0 for GEP arguments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21924 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-13 06:10:12 +00:00
Chris Lattner
641f02f10f Fix Reassociate/shifttest.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21839 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-10 03:39:25 +00:00
Chris Lattner
7f78f218fd If a function contains no allocas, all of the calls in it are trivially
suitable for tail calls.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21836 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-09 23:51:13 +00:00
Chris Lattner
6e4c6495eb implement and.ll:test33
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21809 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-09 04:58:36 +00:00
Chris Lattner
f201dbc1a4 Preserve calling conventions when doing IPO
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21798 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-09 01:05:50 +00:00
Chris Lattner
c154cef9a1 wrap long lines, preserve calling conventions when cloning functions and
turning calls into invokes


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21797 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-09 01:04:34 +00:00
Chris Lattner
fb217adf92 Convert non-address taken functions with C calling conventions to fastcc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21791 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-08 22:18:06 +00:00
Chris Lattner
44b8c7d5d3 Implement Reassociate/mul-neg-add.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21788 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-08 21:41:35 +00:00
Chris Lattner
6f156856ca Bail out earlier
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21786 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-08 21:33:47 +00:00
Chris Lattner
f33151aff0 Teach reassociate that 0-X === X*-1
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21785 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-08 21:28:52 +00:00
Chris Lattner
9c72319938 Fix PR557 and basictest[34].ll.
This makes reassociate realize that loads should be treated as unmovable, and
gives distinct ranks to distinct values defined in the same basic block, allowing
reassociate to do its thing.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21783 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-08 20:57:04 +00:00
Chris Lattner
c9fd097a01 Add debugging information
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21781 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-08 20:09:57 +00:00
Chris Lattner
989f6229bc eliminate gotos
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21780 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-08 19:48:43 +00:00
Chris Lattner
109d34d6ff Improve reassociation handling of inverses, implementing inverses.ll.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21778 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-08 18:59:37 +00:00
Chris Lattner
928128281f clean up and modernize this pass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21776 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-08 18:45:26 +00:00
Chris Lattner
120347e8d1 Strength reduce SAR into SHR if there is no way sign bits could be shifted
in.  This tends to get cases like this:

  X = cast ubyte to int
  Y = shr int X, ...

Tested by: shift.ll:test24


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21775 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-08 17:34:56 +00:00
Chris Lattner
4690010006 Refactor some code
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21772 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-08 00:19:31 +00:00
Chris Lattner
cc8a2b98f2 Handle some simple cases where we can see that values get annihilated.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21771 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-08 00:08:33 +00:00
Chris Lattner
f4d4c87985 Fix a miscompilation of crafty by clobbering the "A" variable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21770 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-07 23:49:08 +00:00
Chris Lattner
c0649ac931 Rewrite the guts of the reassociate pass to be more efficient and logical. Instead
of trying to do local reassociation tweaks at each level, only process an expression
tree once (at its root).  This does not improve the reassociation pass in any real way.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21768 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-07 21:59:39 +00:00
Reid Spencer
789082af03 * Add two strlen optimizations:
strlen(x) != 0 -> *x != 0
    strlen(x) == 0 -> *x == 0
* Change nested statistics to use style of other LLVM statistics so that
  only the name of the optimization (simplify-libcalls) is used as the
  statistic name, and the description indicates which specific all is
  optimized. Cuts down on some redundancy and saves a few bytes of space.
* Make note of stpcpy optimization that could be done.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21766 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-07 20:15:59 +00:00
Reid Spencer
673c1a9170 Don't increment the counter unless the debug flag is set.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21762 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-07 04:59:45 +00:00
Chris Lattner
0975ed5f4e Convert shifts to muls to assist reassociation. This implements
Reassociate/shifttest.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21761 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-07 04:24:13 +00:00
Chris Lattner
08b43921e1 Simplify the code and rearrange it. No major functionality changes here.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21759 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-07 04:08:02 +00:00
Chris Lattner
3799ed83b4 BAD typeo which caused many testsuite failures last night. Note to self, do
not change code after testing it without retesting!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21741 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-06 17:13:16 +00:00
Chris Lattner
a9e9211bbb Preserve tail marker
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21737 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-06 06:48:21 +00:00
Chris Lattner
1b49141821 Implement Transforms/Inline/inline-tail.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21736 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-06 06:47:52 +00:00
Chris Lattner
1430ef134d preserve the tail marker
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21734 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-06 06:46:58 +00:00
Chris Lattner
19bdc03adc Wrap long lines
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21720 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-06 05:34:40 +00:00
Chris Lattner
ec710c5b12 DCE intrinsic instructions without side effects.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21719 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-06 05:27:34 +00:00
Chris Lattner
eabfa4787a Teach instcombine propagate zeroness through shl instructions, implementing
and.ll:test31


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21717 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-06 04:53:20 +00:00
Chris Lattner
d7115b01a0 Implement shift.ll:test23. If we are shifting right then immediately truncating
the result, turn signed shift rights into unsigned shift rights if possible.

This leads to later simplification and happens *often* in 176.gcc.  For example,
this testcase:

struct xxx { unsigned int code : 8; };
enum codes { A, B, C, D, E, F };
int foo(struct xxx *P) {
  if ((enum codes)P->code == A)
     bar();
}

used to be compiled to:

int %foo(%struct.xxx* %P) {
        %tmp.1 = getelementptr %struct.xxx* %P, int 0, uint 0           ; <uint*> [#uses=1]
        %tmp.2 = load uint* %tmp.1              ; <uint> [#uses=1]
        %tmp.3 = cast uint %tmp.2 to int                ; <int> [#uses=1]
        %tmp.4 = shl int %tmp.3, ubyte 24               ; <int> [#uses=1]
        %tmp.5 = shr int %tmp.4, ubyte 24               ; <int> [#uses=1]
        %tmp.6 = cast int %tmp.5 to sbyte               ; <sbyte> [#uses=1]
        %tmp.8 = seteq sbyte %tmp.6, 0          ; <bool> [#uses=1]
        br bool %tmp.8, label %then, label %UnifiedReturnBlock

Now it is compiled to:

        %tmp.1 = getelementptr %struct.xxx* %P, int 0, uint 0           ; <uint*> [#uses=1]
        %tmp.2 = load uint* %tmp.1              ; <uint> [#uses=1]
        %tmp.2 = cast uint %tmp.2 to sbyte              ; <sbyte> [#uses=1]
        %tmp.8 = seteq sbyte %tmp.2, 0          ; <bool> [#uses=1]
        br bool %tmp.8, label %then, label %UnifiedReturnBlock

which is the difference between this:

foo:
        subl $4, %esp
        movl 8(%esp), %eax
        movl (%eax), %eax
        shll $24, %eax
        sarl $24, %eax
        testb %al, %al
        jne .LBBfoo_2

and this:

foo:
        subl $4, %esp
        movl 8(%esp), %eax
        movl (%eax), %eax
        testb %al, %al
        jne .LBBfoo_2

This occurs 3243 times total in the External tests, 215x in povray,
6x in each f2c'd program, 1451x in 176.gcc, 7x in crafty, 20x in perl,
25x in gap, 3x in m88ksim, 25x in ijpeg.

Maybe this will cause a little jump on gcc tommorow :)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21715 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-06 04:18:52 +00:00
Chris Lattner
7aed7ac5e1 Implement xor.ll:test22
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21713 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-06 02:07:39 +00:00
Chris Lattner
d152380ba8 implement and.ll:test30 and set.ll:test21
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21712 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-06 01:53:19 +00:00
Chris Lattner
828eeddb38 implement or.ll:test20
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21709 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-06 00:58:50 +00:00
Chris Lattner
3987abdfe3 Fix a bug compimling Ruby, fixing this testcase:
LowerSetJmp/2005-05-05-OldUses.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21696 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-05 15:47:43 +00:00
Chris Lattner
693787a5ec Instcombine: cast (X != 0) to int, cast (X == 1) to int -> X iff X has only the low bit set.
This implements set.ll:test20.

This triggers 2x on povray, 9x on mesa, 11x on gcc, 2x on crafty, 1x on eon,
6x on perlbmk and 11x on m88ksim.

It allows us to compile these two functions into the same code:

struct s { unsigned int bit : 1; };
unsigned foo(struct s *p) {
  if (p->bit)
    return 1;
  else
    return 0;
}
unsigned bar(struct s *p) { return p->bit; }


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21690 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-04 19:10:26 +00:00
Reid Spencer
cea6559f60 Implement the IsDigitOptimization for simplifying calls to the isdigit
library function:
  isdigit(chr) -> 0 or 1 if chr is constant
  isdigit(chr) -> chr - '0' <= 9 otherwise

Although there are many calls to isdigit in llvm-test, most of them are
compiled away by macros leaving only this:

2 MultiSource/Applications/hexxagon


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21688 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-04 18:58:28 +00:00
Reid Spencer
58b563ce43 * Correct the function prototypes for some of the functions to match the
actual spec (int -> uint)
* Add the ability to get/cache the strlen function prototype.
* Make sure generated values are appropriately named for debugging purposes
* Add the SPrintFOptimiation for 4 casts of sprintf optimization:
    sprintf(str,cstr) -> llvm.memcpy(str,cstr) (if cstr has no %)
    sprintf(str,"")   -> store sbyte 0, str
    sprintf(str,"%s",src) -> llvm.memcpy(str,src) (if src is constant)
    sprintf(str,"%c",chr) -> store chr, str   ; store sbyte 0, str+1

The sprintf optimization didn't fire as much as I had hoped:

  2 MultiSource/Applications/SPASS
  5 MultiSource/Benchmarks/McCat/18-imp
 22 MultiSource/Benchmarks/Prolangs-C/TimberWolfMC
  1 MultiSource/Benchmarks/Prolangs-C/assembler
  6 MultiSource/Benchmarks/Prolangs-C/unix-smail
  2 MultiSource/Benchmarks/mediabench/mpeg2/mpeg2dec


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21679 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-04 03:20:21 +00:00
Reid Spencer
21506ff821 Implement optimizations for the strchr and llvm.memset library calls.
Neither of these activated as many times as was hoped:

strchr:
9 MultiSource/Applications/siod
1 MultiSource/Applications/d
2 MultiSource/Prolangs-C/archie-client
1 External/SPEC/CINT2000/176.gcc/176.gcc

llvm.memset:
no hits


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21669 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-03 07:23:44 +00:00
Reid Spencer
9974ddab2b Avoid garbage output in the statistics display by ensuring that the
strings passed to Statistic's constructor are not destructable. The stats
are printed during static destruction and the SimplifyLibCalls module was
getting destructed before the statistics.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21661 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-03 02:54:54 +00:00
Reid Spencer
e6ec8cc8c6 Add the StrNCmpOptimization which is similar to strcmp.
Unfortunately, this optimization didn't trigger on any llvm-test tests.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21660 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-03 01:43:45 +00:00
Reid Spencer
a1b4390938 Implement the fprintf optimization which converts calls like this:
fprintf(F,"hello") -> fwrite("hello",strlen("hello"),1,F)
  fprintf(F,"%s","hello") -> fwrite("hello",strlen("hello"),1,F)
  fprintf(F,"%c",'x') -> fputc('c',F)

This optimization fires severals times in llvm-test:

313 MultiSource/Applications/Burg
302 MultiSource/Benchmarks/Prolangs-C/TimberWolfMC
189 MultiSource/Benchmarks/Prolangs-C/mybison
175 MultiSource/Benchmarks/Prolangs-C/football
130 MultiSource/Benchmarks/Prolangs-C/unix-tbl


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21657 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-02 23:59:26 +00:00
John Criswell
fe3706a12b Fixed a comment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21653 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-02 14:47:42 +00:00
Chris Lattner
9fb25db11e Implement getelementptr.ll:test11
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21647 91177308-0d34-0410-b5e6-96231b3b80d8
2005-05-01 04:42:15 +00:00