Commit Graph

18689 Commits

Author SHA1 Message Date
Misha Brukman 3f670d29dc * Use consistent spacing for function arguments
* Output single-character strings as chars

llvm-svn: 21705
2005-05-05 22:38:21 +00:00
Misha Brukman 291f6b7223 Remove vim settings from source code; people should use llvm/utils/vim/vimrc
llvm-svn: 21704
2005-05-05 22:33:09 +00:00
Misha Brukman 08d66b4e10 Convert tabs to spaces
llvm-svn: 21703
2005-05-05 22:30:40 +00:00
Chris Lattner 4a454c80db new testcase for PR541
llvm-svn: 21702
2005-05-05 22:23:10 +00:00
Chris Lattner 1243e1c9f1 add support for undef values of opaque type, addressing PR541
llvm-svn: 21701
2005-05-05 22:21:19 +00:00
Chris Lattner 7ddaeb448b Add some extra checks. Opaque types don't have a null marker.
llvm-svn: 21700
2005-05-05 20:57:00 +00:00
Chris Lattner 2cc59a8066 new testcase
llvm-svn: 21699
2005-05-05 17:57:24 +00:00
Chris Lattner 7876156ba0 When hitting an unsupported intrinsic, actually print it
Lower debug info to noops.

llvm-svn: 21698
2005-05-05 17:55:17 +00:00
Andrew Lenharth 2dbbb3ab84 ctpop lowering in legalize
llvm-svn: 21697
2005-05-05 15:55:21 +00:00
Chris Lattner 807aa20f67 Fix a bug compimling Ruby, fixing this testcase:
LowerSetJmp/2005-05-05-OldUses.ll

llvm-svn: 21696
2005-05-05 15:47:43 +00:00
Chris Lattner fa58898845 new testcase for a bug Jim found
llvm-svn: 21695
2005-05-05 15:47:16 +00:00
Andrew Lenharth b8e94c3499 fix typo
llvm-svn: 21693
2005-05-04 19:25:37 +00:00
Andrew Lenharth aed06a0e92 Well, add support for ct* for 21264 only.
21164 is broken until expand works.

llvm-svn: 21692
2005-05-04 19:12:09 +00:00
Andrew Lenharth dd426dd04d Make promoteOp work for CT*
Proof?

ubyte %bar(ubyte %x) {
entry:
        %tmp.1 = call ubyte %llvm.ctlz( ubyte %x )
        ret ubyte %tmp.1
}

==>

zapnot $16,1,$0
CTLZ $0,$0
subq $0,56,$0
zapnot $0,1,$0
ret $31,($26),1

llvm-svn: 21691
2005-05-04 19:11:05 +00:00
Chris Lattner 809dfac421 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; }

llvm-svn: 21690
2005-05-04 19:10:26 +00:00
Chris Lattner 3538a4f6cc new testcase
llvm-svn: 21689
2005-05-04 19:05:02 +00:00
Reid Spencer 282d057485 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

llvm-svn: 21688
2005-05-04 18:58:28 +00:00
Reid Spencer f9a4a9681d Make sure both optimization cases get tested.
llvm-svn: 21687
2005-05-04 17:45:10 +00:00
Reid Spencer 190bb26157 Add a test case for the IsDigitOptimization class.
llvm-svn: 21686
2005-05-04 17:34:55 +00:00
Andrew Lenharth 702859084b comment fix
llvm-svn: 21685
2005-05-04 15:56:34 +00:00
Andrew Lenharth dd9d3ac72b see if the legalize code propery compensates for the additional zeros introduced
llvm-svn: 21684
2005-05-04 15:51:07 +00:00
Reid Spencer e84ee1bcd0 Correct the descriptions of WHILE...END and RROT. Thanks to Lalo Martins
for pointing out these errors.

llvm-svn: 21683
2005-05-04 15:43:40 +00:00
Reid Spencer 7063d1aa71 WHILE does not "pop" a value, it "examines" to top of stack. Make this
clear in the applicable comment.

llvm-svn: 21682
2005-05-04 15:33:48 +00:00
Andrew Lenharth 6b551024ac added a use of ctpop to debug stuff with
llvm-svn: 21681
2005-05-04 15:20:16 +00:00
Andrew Lenharth 5be6f131e6 fixup argument
llvm-svn: 21680
2005-05-04 14:58:31 +00:00
Reid Spencer 1e520fd661 * 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

llvm-svn: 21679
2005-05-04 03:20:21 +00:00
Misha Brukman 23e9f163ad Minor clean-ups
llvm-svn: 21678
2005-05-03 20:30:34 +00:00
Andrew Lenharth 1d463526b4 initial descriptions of count intrinsics
llvm-svn: 21677
2005-05-03 18:01:48 +00:00
Andrew Lenharth 5e177826fd Implement count leading zeros (ctlz), count trailing zeros (cttz), and count
population (ctpop).  Generic lowering is implemented, however only promotion
is implemented for SelectionDAG at the moment.

More coming soon.

llvm-svn: 21676
2005-05-03 17:19:30 +00:00
Reid Spencer f436286cf6 Fix this test to succeed even if "strchr" is on a call instruction.
llvm-svn: 21675
2005-05-03 17:09:38 +00:00
Reid Spencer a6bbd18023 Add a test case for SPrintFOptimization.
llvm-svn: 21674
2005-05-03 17:08:45 +00:00
Andrew Lenharth 38cc7bacb4 yea yea yea
llvm-svn: 21673
2005-05-03 17:00:48 +00:00
Andrew Lenharth 2e18c628c4 note the vararg change, and other stuff
llvm-svn: 21672
2005-05-03 16:59:09 +00:00
Andrew Lenharth bf50ff58ae pre add count tests
llvm-svn: 21671
2005-05-03 16:49:48 +00:00
Chris Lattner c22333348e fix a bug in the 1 index GEP handling code
llvm-svn: 21670
2005-05-03 16:44:45 +00:00
Reid Spencer 38cabd7265 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

llvm-svn: 21669
2005-05-03 07:23:44 +00:00
Reid Spencer a064a84067 Add a test case for StrChrOptimizer for -simplify-libcalls
llvm-svn: 21668
2005-05-03 06:22:41 +00:00
Misha Brukman d317d937b2 Clean up and correct llvmc configurations for C and C++
llvm-svn: 21667
2005-05-03 06:13:18 +00:00
Misha Brukman 18aa1d6438 std::string(NULL) does not a proper constructor make
llvm-svn: 21666
2005-05-03 06:10:51 +00:00
Chris Lattner 8298120f17 add direct support for making GEP instrs with one index
llvm-svn: 21665
2005-05-03 05:43:30 +00:00
Misha Brukman cc42755633 Omit periods at the end of command-line switch explanations for consistency
llvm-svn: 21664
2005-05-03 05:36:14 +00:00
Reid Spencer d18dbcbf4c A new test case for the LLVMMemSetOptimization.
llvm-svn: 21663
2005-05-03 04:00:24 +00:00
Jeff Cohen 4e3aedeaa6 Use ANSI-approved way of getting the value infinity (otherwise VC++ won't compile it)
llvm-svn: 21662
2005-05-03 03:13:01 +00:00
Reid Spencer 95d8efdfcf 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.

llvm-svn: 21661
2005-05-03 02:54:54 +00:00
Reid Spencer 49fa070401 Add the StrNCmpOptimization which is similar to strcmp.
Unfortunately, this optimization didn't trigger on any llvm-test tests.

llvm-svn: 21660
2005-05-03 01:43:45 +00:00
Reid Spencer 8204531db1 Correct the title and the success criteria: strcmp -> strncmp
llvm-svn: 21659
2005-05-03 00:52:19 +00:00
Reid Spencer 0a23afbedb Add a new test case for the StrNCmpOptimization.
llvm-svn: 21658
2005-05-03 00:50:43 +00:00
Reid Spencer 2d5c7beebd 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

llvm-svn: 21657
2005-05-02 23:59:26 +00:00
Reid Spencer 59605a1b57 Add a test case for testing the FPrintFOptimization.
llvm-svn: 21656
2005-05-02 23:07:14 +00:00
Andrew Lenharth c73e633a41 fold fp div by 0 to inf, the way gcc does. This is legal according to the FP spec
llvm-svn: 21655
2005-05-02 21:25:47 +00:00
Andrew Lenharth f5d58d1bc3 Remove support for 1.0 style varargs
amusing of course, because we will have to go back to those semantics soon

llvm-svn: 21654
2005-05-02 19:07:27 +00:00
John Criswell f42ed7bdaf Fixed a comment.
llvm-svn: 21653
2005-05-02 14:47:42 +00:00
Duraid Madina 7acd5d5f06 support multiplication by constant negative integers
this constmul code is still buggy though, so beware. mul by 7427 is currently
broken, for example. will fix it when I get a moment :)

llvm-svn: 21652
2005-05-02 07:27:14 +00:00
Duraid Madina 0e73188c10 add support for bools to SELECT, this fixes Prolangs-C/bison from the
testsuite, however 09-vor is still dead (hopefully for other reasons!)

llvm-svn: 21651
2005-05-02 06:41:13 +00:00
Reid Spencer d845d160f6 Mention that arguments to functions must be first class types.
llvm-svn: 21650
2005-05-01 22:22:57 +00:00
Tanya Lattner 846b8b00e2 Add accessor method,
llvm-svn: 21649
2005-05-01 16:22:41 +00:00
Tanya Lattner c187835632 Adding ModuloSched SB.
llvm-svn: 21648
2005-05-01 16:14:34 +00:00
Chris Lattner a816eee427 Implement getelementptr.ll:test11
llvm-svn: 21647
2005-05-01 04:42:15 +00:00
Chris Lattner cdb2465152 new testcase
llvm-svn: 21646
2005-05-01 04:41:57 +00:00
Chris Lattner a9d84e3388 Check for volatile loads only once.
Implement load.ll:test7

llvm-svn: 21645
2005-05-01 04:24:53 +00:00
Chris Lattner da96eeb2d5 add a new testcase
llvm-svn: 21644
2005-05-01 04:24:15 +00:00
Tanya Lattner 9d43c75a55 SMS for superblocks.
llvm-svn: 21643
2005-05-01 01:27:47 +00:00
Tanya Lattner bdfb9e61a0 Added extra constructor for superblocks.
llvm-svn: 21642
2005-05-01 01:25:53 +00:00
Tanya Lattner 4d0ee754e3 Fixed bug in searchPath function for finding nodes between two recurrences.
Changed dependence analyzer to only use dep distances of 2 or less.
This is experimental.

Changed MSchedGraph to be able to represent more then one BB (first steps).

llvm-svn: 21641
2005-04-30 23:07:59 +00:00
Andrew Lenharth 537332eba8 I was sure I had thought about this and there was a reason it should work.
But it is entirely possible I am just crazy.

llvm-svn: 21640
2005-04-30 14:19:13 +00:00
Alkis Evlogimenos d7e534b2b3 Do not use deprecated APIs
llvm-svn: 21639
2005-04-30 07:13:31 +00:00
Reid Spencer 16449a9eb0 Fix a comment that stated the wrong thing.
llvm-svn: 21638
2005-04-30 06:45:47 +00:00
Chris Lattner c8a6633dea Eliminate some random whitespace
llvm-svn: 21637
2005-04-30 04:44:07 +00:00
Chris Lattner 8002640eab Codegen and legalize sin/cos/llvm.sqrt as FSIN/FCOS/FSQRT calls. This patch
was contributed by Morten Ofstad, with some minor tweaks and bug fixes added
by me.

llvm-svn: 21636
2005-04-30 04:43:14 +00:00
Chris Lattner 9efa7e7533 add sin/cos tests
llvm-svn: 21635
2005-04-30 04:41:27 +00:00
Chris Lattner 9993823876 Doesn't support these nodes
llvm-svn: 21634
2005-04-30 04:26:56 +00:00
Chris Lattner 9c6bbafc15 This target doesn't support the FSIN/FCOS/FSQRT nodes yet
llvm-svn: 21633
2005-04-30 04:26:06 +00:00
Chris Lattner db68d39a01 Add support for FSIN/FCOS when unsafe math ops are enabled. Patch contributed by
Morten Ofstad!

llvm-svn: 21632
2005-04-30 04:25:35 +00:00
Chris Lattner 3b20386551 Add support for llvm.sqrt and sin/cos if unsafe math optimizations are enabled.
llvm-svn: 21631
2005-04-30 04:12:40 +00:00
Chris Lattner 4a2cc6603d Expose an option allowing unsafe math optimizations. Patch contributed by
Morten Ofstad!

llvm-svn: 21630
2005-04-30 04:09:52 +00:00
Chris Lattner 30fe4ac2fb Lower llvm.sqrt -> fsqrt/sqrt
llvm-svn: 21629
2005-04-30 04:07:50 +00:00
Chris Lattner 7100fcde6c Add a test for llvm.sqrt
llvm-svn: 21628
2005-04-30 04:07:15 +00:00
Chris Lattner 1c636f1118 Add llvm.sqrt intrinsic, patch contributed by Morten Ofstad
llvm-svn: 21627
2005-04-30 03:44:07 +00:00
Reid Spencer 4c444fe007 * Don't depend on "guessing" what a FILE* is, just require that the actual
type be obtained from a CallInst we're optimizing.
* Make it possible for getConstantStringLength to return the ConstantArray
  that it extracts in case the content is needed by an Optimization.
* Implement the strcmp optimization
* Implement the toascii optimization

This pass is now firing several to many times in the following MultiSource
tests:

Applications/Burg      -   7 (strcat,strcpy)
Applications/siod      -  13 (strcat,strcpy,strlen)
Applications/spiff     - 120 (exit,fputs,strcat,strcpy,strlen)
Applications/treecc    -  66 (exit,fputs,strcat,strcpy)
Applications/kimwitu++ -  34 (strcmp,strcpy,strlen)
Applications/SPASS     - 588 (exit,fputs,strcat,strcpy,strlen)

llvm-svn: 21626
2005-04-30 03:17:54 +00:00
Reid Spencer 29c6b848db * Fix signed/unsigned usage problem
* Rearrange for readability.

llvm-svn: 21625
2005-04-30 03:06:36 +00:00
Reid Spencer 10e99b2667 A new test case for the ToAsciiOptimizer.
llvm-svn: 21624
2005-04-30 01:00:52 +00:00
Reid Spencer 89339ffb22 A new test case for the StrCmpOptimization in -simplify-libcalls.
llvm-svn: 21623
2005-04-30 00:52:04 +00:00
Reid Spencer 1279398b1c This is StrCpy, NOT StrCat!
llvm-svn: 21622
2005-04-29 23:02:15 +00:00
Reid Spencer cadbe2bbf1 Get the name of the pass right in the documentation.
llvm-svn: 21621
2005-04-29 23:01:21 +00:00
Reid Spencer a2ddce3119 Fix the success criteria for the test to make call instructions with "pow"
not just any occurrence of "pow".

llvm-svn: 21620
2005-04-29 10:11:23 +00:00
Reid Spencer 9610da2670 Actually make this pass test something related to fputs.
llvm-svn: 21619
2005-04-29 10:10:17 +00:00
Reid Spencer 9361697f93 Implement the optimizations for "pow" and "fputs" library calls.
llvm-svn: 21618
2005-04-29 09:39:47 +00:00
Reid Spencer fc4cf1d435 Add a test case for the puts libcall optimization.
llvm-svn: 21616
2005-04-29 07:19:00 +00:00
Reid Spencer 2645640325 Add a testcase for optimizing the strcpy libcall.
llvm-svn: 21615
2005-04-29 06:01:28 +00:00
Reid Spencer c968ea0495 Remove optimizations that don't require both operands to be constant. These
are moved to simplify-libcalls pass.

llvm-svn: 21614
2005-04-29 05:55:35 +00:00
Reid Spencer a8b889490e New test case for testing pow(3) math library optimizations.
llvm-svn: 21613
2005-04-29 05:47:05 +00:00
Jeff Cohen 4bc952f703 Consistently use 'class' to silence VC++
llvm-svn: 21612
2005-04-29 03:05:44 +00:00
Reid Spencer ed55a6b5e0 * Add constant folding for additional floating point library calls such as
sinh, cosh, etc.
* Make the name comparisons for the fp libcalls a little more efficient by
  switching on the first character of the name before doing comparisons.

llvm-svn: 21611
2005-04-28 23:01:59 +00:00
Chris Lattner 014d2c42e7 Add support for FSQRT node, patch contributed by Morten Ofstad
llvm-svn: 21610
2005-04-28 22:07:18 +00:00
Chris Lattner 59ecb57e4a These functions can set errno!
llvm-svn: 21609
2005-04-28 21:52:31 +00:00
Chris Lattner 61827484c7 Add some new X86 instrs, patch contributed by Morten Ofstad
llvm-svn: 21608
2005-04-28 21:50:05 +00:00
Chris Lattner effaec5436 Codegen fabs/fabsf as FABS. Patch contributed by Morten Ofstad
llvm-svn: 21607
2005-04-28 21:48:42 +00:00
Chris Lattner 9d6fa98ec7 Legalize FSQRT, FSIN, FCOS nodes, patch contributed by Morten Ofstad
llvm-svn: 21606
2005-04-28 21:44:33 +00:00
Chris Lattner 2f82d2d58a Add FSQRT, FSIN, FCOS nodes, patch contributed by Morten Ofstad
llvm-svn: 21605
2005-04-28 21:44:03 +00:00
Reid Spencer 16983ca865 Remove from the TODO list those optimizations that are already handled by
constant folding implemented in lib/Transforms/Utils/Local.cpp.

llvm-svn: 21604
2005-04-28 18:05:16 +00:00
Reid Spencer 649ac283e4 Document additional libcall transformations that need to be written.
Help Wanted!

There's a lot of them to write.

llvm-svn: 21603
2005-04-28 04:40:06 +00:00
Reid Spencer 7ddcfb3375 Doxygenate.
llvm-svn: 21602
2005-04-27 21:29:20 +00:00
Chris Lattner 36ffb1ff37 remove 'statement with no effect' warning
llvm-svn: 21600
2005-04-27 20:12:17 +00:00
Andrew Lenharth 4a73c2cfdc Implement Value* tracking for loads and stores in the selection DAG. This enables one to use alias analysis in the backends.
(TRUNK)Stores and (EXT|ZEXT|SEXT)Loads have an extra SDOperand which is a SrcValueSDNode which contains the Value*.  Note that if the operation is introduced by the backend, it will still have the operand, but the value* will be null.

llvm-svn: 21599
2005-04-27 20:10:01 +00:00
Chris Lattner 0a6f42ac1d Unbreak the sparc backend.
llvm-svn: 21598
2005-04-27 18:57:15 +00:00
Reid Spencer 08b4940509 More Cleanup:
* Name the instructions by appending to name of original
* Factor common part out of a switch statement.

llvm-svn: 21597
2005-04-27 17:46:54 +00:00
Andrew Lenharth 3b63291fc1 import fix and plot multiple lines at once
llvm-svn: 21596
2005-04-27 17:32:41 +00:00
Andrew Lenharth 438225a8cb Generate a gnuplot script for any program and any test (like llc or gcc)
llvm-svn: 21593
2005-04-27 16:41:50 +00:00
Andrew Lenharth e81871331f So you want to import nightly tester data into a data base? Have we got the perl script for you
llvm-svn: 21592
2005-04-27 16:03:01 +00:00
Andrew Lenharth be6ce82937 fix for parse, and a start at db import. Using CVS as scp :)
llvm-svn: 21591
2005-04-27 14:57:26 +00:00
Duraid Madina b071bef66a clean up some warnings
llvm-svn: 21590
2005-04-27 11:57:39 +00:00
Reid Spencer e249a82e73 This is a cleanup commit:
* Correct stale documentation in a few places
* Re-order the file to better associate things and reduce line count
* Make the pass thread safe by caching the Function* objects needed by the
  optimizers in the pass object instead of globally.
* Provide the SimplifyLibCalls pass object to the optimizer classes so they
  can access cached Function* objects and TargetData info
* Make sure the pass resets its cache if the Module passed to runOnModule
  changes
* Rename CallOptimizer LibCallOptimization. All the classes are named
  *Optimization while the objects are *Optimizer.
* Don't cache Function* in the optimizer objects because they could be used
  by multiple PassManager's running in multiple threads
* Add an optimization for strcpy which is similar to strcat
* Add a "TODO" list at the end of the file for ideas on additional libcall
  optimizations that could be added (get ideas from other compilers).

Sorry for the huge diff. Its mostly reorganization of code. That won't
happen again as I believe the design and infrastructure for this pass is
now done or close to it.

llvm-svn: 21589
2005-04-27 07:54:40 +00:00
Chris Lattner 93f4e9dd26 detect functions that never return, and turn the instruction following a
call to them into an 'unreachable' instruction.

This triggers a bunch of times, particularly on gcc:

gzip: 36
gcc: 601
eon: 12
bzip: 38
llvm-svn: 21587
2005-04-27 04:52:23 +00:00
Chris Lattner 356cbfef73 Test the noreturn function optimization
llvm-svn: 21586
2005-04-27 04:51:01 +00:00
Reid Spencer a21f83f809 Add the simplify-libcalls pass.
llvm-svn: 21585
2005-04-27 02:22:47 +00:00
Andrew Lenharth 9b3114d4ed A first step towards being able to do more interesting things with the nightly tester data. Moreinteresting things will come soon, so tune in
llvm-svn: 21584
2005-04-27 02:13:20 +00:00
Reid Spencer dc11db68b6 Prefix the debug statistics so they group together.
llvm-svn: 21583
2005-04-27 00:20:23 +00:00
Reid Spencer e95a647b2a In debug builds, make a statistic for each kind of call optimization. This
helps track down what gets triggered in the pass so its easier to identify
good test cases.

llvm-svn: 21582
2005-04-27 00:05:45 +00:00
Chris Lattner 7f4f773e9f This analysis doesn't take 'throwing' into consideration, it looks at
'unwinding'

llvm-svn: 21581
2005-04-26 23:53:25 +00:00
Reid Spencer f9d4be187f Fix up the debug statement to actually use a newline .. radical concept.
llvm-svn: 21580
2005-04-26 23:07:08 +00:00
Reid Spencer 18b998192f Uh, this isn't argpromotion.
llvm-svn: 21579
2005-04-26 23:05:17 +00:00
Reid Spencer 2bc7a4f82a Add some debugging output so we can tell which calls are getting triggered
llvm-svn: 21578
2005-04-26 23:02:16 +00:00
Chris Lattner 2bfe36214d no parens
llvm-svn: 21577
2005-04-26 22:57:07 +00:00
Chris Lattner 730a5da1af update some paths
llvm-svn: 21576
2005-04-26 22:56:16 +00:00
Reid Spencer f8c03d9db6 No, seriously folks, memcpy really does return void.
llvm-svn: 21575
2005-04-26 22:49:48 +00:00
Reid Spencer aaca170867 memcpy returns void!!!!!
llvm-svn: 21574
2005-04-26 22:46:23 +00:00
Reid Spencer 7821d06c24 Convert the remainder of the intrinsic function prototypes to "declare"
form from the "call" form.

llvm-svn: 21573
2005-04-26 20:50:44 +00:00
Reid Spencer cf669d87d0 Use the declare syntax not the call syntax for intrinsic prototypes so
the uninitiated reader is not confused.

llvm-svn: 21572
2005-04-26 20:41:16 +00:00
Chris Lattner 41d183ed8d don't let Reid build void*'s :)
llvm-svn: 21571
2005-04-26 20:03:33 +00:00
Reid Spencer 4855ebf622 Fix some bugs found by running on llvm-test:
* MemCpyOptimization can only be optimized if the 3rd and 4th arguments are
  constants and we weren't checking for that.
* The result of llvm.memcpy (and llvm.memmove) is void* not sbyte*, put in
  a cast.

llvm-svn: 21570
2005-04-26 19:55:57 +00:00
Reid Spencer bb92b4fdfb Changes From Review Feedback:
* Have the SimplifyLibCalls pass acquire the TargetData and pass it down to
  the optimization classes so they can use it to make better choices for
  the signatures of functions, etc.
* Rearrange the code a little so the utility functions are closer to their
  usage and keep the core of the pass near the top of the files.
* Adjust the StrLen pass to get/use the correct prototype depending on the
  TargetData::getIntPtrType() result. The result of strlen is size_t which
  could be either uint or ulong depending on the platform.
* Clean up some coding nits (cast vs. dyn_cast, remove redundant items from
  a switch, etc.)
* Implement the MemMoveOptimization as a twin of MemCpyOptimization (they
  only differ in name).

llvm-svn: 21569
2005-04-26 19:13:17 +00:00
Reid Spencer 61a18b84cc Add a test case for MemMove.ll
llvm-svn: 21568
2005-04-26 19:05:51 +00:00
Reid Spencer abeb186371 Result of strlen is size_t which is either uint or ulong, not int.
llvm-svn: 21567
2005-04-26 19:04:46 +00:00
Chris Lattner eb2a461acf Make interval partition print correctly, patch contributed by
Vladimir Prus!

llvm-svn: 21566
2005-04-26 14:48:28 +00:00
Chris Lattner bd43b9db9d Fix the compile failures from last night.
llvm-svn: 21565
2005-04-26 14:40:41 +00:00
Duraid Madina e06ef80244 constmul bugfix: multiply by 27611 was broken
llvm-svn: 21564
2005-04-26 09:42:50 +00:00
Duraid Madina bbd0cd71a8 clean up the code! (oops) lots more cleaning left, however.
llvm-svn: 21563
2005-04-26 08:43:47 +00:00
Reid Spencer b4f7b83dce * Merge get_GVInitializer and getCharArrayLength into a single function
named getConstantStringLength. This is the common part of StrCpy and
  StrLen optimizations and probably several others, yet to be written. It
  performs all the validity checks for looking at constant arrays that are
  supposed to be null-terminated strings and then computes the actual
  length of the string.
* Implement the MemCpyOptimization class. This just turns memcpy of 1, 2, 4
  and 8 byte data blocks that are properly aligned on those boundaries into
  a load and a store. Much more could be done here but alignment
  restrictions and lack of knowledge of the target instruction set prevent
  use from doing significantly more. That will have to be delegated to the
  code generators as they lower llvm.memcpy calls.

llvm-svn: 21562
2005-04-26 07:45:18 +00:00
Reid Spencer 89011b6f3c Add a new test case for the llvm.memcpy simplification case.
llvm-svn: 21561
2005-04-26 07:40:40 +00:00
Duraid Madina 81ebb57771 * Add code to reduce multiplies by constant integers to shifts, adds and
subtracts. This is a very rough and nasty implementation of Lefevre's
  "pattern finding" algorithm. With a few small changes though, it should
  end up beating most other methods in common use, regardless of the size
  of the constant (currently, it's often one or two shifts worse)

  TODO: rewrite it so it's not hideously ugly (this is a translation from
        perl, which doesn't help ;)
        bypass most of it for multiplies by 2^n+1
	(eventually) teach it that some combinations of shift+add are
	cheaper than others (e.g. shladd on ia64, scaled adds on alpha)
	get it to try multiple booth encodings in search of the cheapest
	routine
	make it work for negative constants

  This is hacked up as a DAG->DAG transform, so once I clean it up I hope
  it'll be pulled out of here and put somewhere else. The only thing backends
  should really have to worry about for now is where to draw the line
  between using this code vs. going ahead and doing an integer multiply
  anyway.

llvm-svn: 21560
2005-04-26 07:23:02 +00:00
Reid Spencer 76dab9a523 * Implement StrLenOptimization
* Factor out commonalities between StrLenOptimization and StrCatOptimization
* Make sure that signatures return sbyte* not void*

llvm-svn: 21559
2005-04-26 05:24:00 +00:00
Reid Spencer 3f2710e64e * Add a test case for StrLenOptimization
* Rename ExitInMain and StrCat tests so they don't have the date the
  regression was entered since they are feature tests, not regressions.

llvm-svn: 21558
2005-04-26 05:22:38 +00:00
Reid Spencer 8ee5aacc38 Incorporate feedback from Chris:
* Change signatures of OptimizeCall and ValidateCalledFunction so they are
  non-const, allowing the optimization object to be modified. This is in
  support of caching things used across multiple calls.
* Provide two functions for constructing and caching function types
* Modify the StrCatOptimization to cache Function objects for strlen and
  llvm.memcpy so it doesn't regenerate them on each call site. Make sure
  these are invalidated each time we start the pass.
* Handle both a GEP Instruction and a GEP ConstantExpr
* Add additional checks to make sure we really are dealing with an arary of
  sbyte and that all the element initializers are ConstantInt or
  ConstantExpr that reduce to ConstantInt.
* Make sure the GlobalVariable is constant!
* Don't use ConstantArray::getString as it can fail and it doesn't give us
  the right thing. We must check for null bytes in the middle of the array.
* Use llvm.memcpy instead of memcpy so we can factor alignment into it.
* Don't use void* types in signatures, replace with sbyte* instead.

llvm-svn: 21555
2005-04-26 03:26:15 +00:00
Jeff Cohen d45bdb45c1 Add SimplyLibCalls.cpp to VC++ build
llvm-svn: 21554
2005-04-26 02:57:49 +00:00
Reid Spencer 342fe9a833 Fix RUN: line to not always pass.
llvm-svn: 21553
2005-04-26 02:33:25 +00:00
Chris Lattner cfa7ddd6e2 Fold (X > -1) | (Y > -1) --> (X&Y > -1)
llvm-svn: 21552
2005-04-26 01:18:33 +00:00
Reid Spencer fe91dfec91 Changes due to code review and new implementation:
* Don't use std::string for the function names, const char* will suffice
* Allow each CallOptimizer to validate the function signature before
  doing anything
* Repeatedly loop over the functions until an iteration produces
  no more optimizations. This allows one optimization to insert a
  call that is optimized by another optimization.
* Implement the ConstantArray portion of the StrCatOptimization
* Provide a template for the MemCpyOptimization
* Make ExitInMainOptimization split the block, not delete everything
  after the return instruction.
(This covers revision 1.3 and 1.4, as the 1.3 comments were botched)

llvm-svn: 21548
2005-04-25 21:20:38 +00:00
Chris Lattner f806459d90 implement some more logical compares with constants, so that:
int foo1(int x, int y) {
  int t1 = x >= 0;
  int t2 = y >= 0;
  return t1 & t2;
}
int foo2(int x, int y) {
  int t1 = x == -1;
  int t2 = y == -1;
  return t1 & t2;
}

produces:

_foo1:
        or r2, r4, r3
        srwi r2, r2, 31
        xori r3, r2, 1
        blr
_foo2:
        and r2, r4, r3
        addic r2, r2, 1
        li r2, 0
        addze r3, r2
        blr

instead of:

_foo1:
        srwi r2, r4, 31
        xori r2, r2, 1
        srwi r3, r3, 31
        xori r3, r3, 1
        and r3, r2, r3
        blr
_foo2:
        addic r2, r4, 1
        li r2, 0
        addze r2, r2
        addic r3, r3, 1
        li r3, 0
        addze r3, r3
        and r3, r2, r3
        blr

llvm-svn: 21547
2005-04-25 21:20:28 +00:00
Reid Spencer f2534c7291 Lots of changes based on review and new functionality:
* Use a 

llvm-svn: 21546
2005-04-25 21:11:48 +00:00
Reid Spencer 172e9155c1 Update the test case to handle a few more (degenerate) cases and remove
the restriction that it is an XFAIL because it now passes.

llvm-svn: 21545
2005-04-25 21:08:34 +00:00
Chris Lattner d373ff64aa Codegen x < 0 | y < 0 as (x|y) < 0. This allows us to compile this to:
_foo:
        or r2, r4, r3
        srwi r3, r2, 31
        blr

instead of:

_foo:
        srwi r2, r4, 31
        srwi r3, r3, 31
        or r3, r2, r3
        blr

llvm-svn: 21544
2005-04-25 21:03:25 +00:00
Chris Lattner e093c6f565 Make dominates(A,B) work with post dominators. Patch contributed by
Naveen Neelakantam, thanks!

llvm-svn: 21543
2005-04-25 20:50:33 +00:00
Tanya Lattner af0ac2744e Added question about turning off all optimizations. I think this has been asked once or twice.
llvm-svn: 21542
2005-04-25 20:36:56 +00:00
Chris Lattner a21bf8d1be implement getelementptr.ll:test10
llvm-svn: 21541
2005-04-25 20:17:30 +00:00
Chris Lattner 20621b1e94 rename fn
llvm-svn: 21540
2005-04-25 20:17:16 +00:00
Chris Lattner e680ee2a48 new testcase
llvm-svn: 21539
2005-04-25 20:17:00 +00:00
Chris Lattner ecac782786 Correctly handle global-argument aliases induced in main
llvm-svn: 21537
2005-04-25 19:16:31 +00:00
Chris Lattner 5965359d8f Don't mess up SCC traversal when a node has null edges out of it.
llvm-svn: 21536
2005-04-25 19:16:17 +00:00
Chris Lattner 37b6b097ff document 'opaque' types
llvm-svn: 21535
2005-04-25 17:34:15 +00:00
Chris Lattner d1039cc581 Add feedback from Vikram
llvm-svn: 21534
2005-04-25 15:47:57 +00:00
Reid Spencer 478d3b930a Make sure the target buffer is null terminated so we don't blow up
strcat when its called.

llvm-svn: 21533
2005-04-25 15:40:35 +00:00
Reid Spencer 20b0e43e1f A test case for testing the StrCatOptimizer, currently XFAILed everywhere.
llvm-svn: 21532
2005-04-25 07:29:30 +00:00
Reid Spencer 9bbaa2ab7f Post-Review Cleanup:
* Fix comments at top of file
* Change algorithm for running the call optimizations from n*n to something
  closer to n.
* Use a hash_map to store and lookup the optimizations since there will
  eventually (or potentially) be a large number of them. This gets lookup
  based on the name of the function to O(1). Each CallOptimizer now has a
  std::string member named func_name that tracks the name of the function
  that it applies to. It is this string that is entered into the hash_map
  for fast comparison against the function names encountered in the module.
* Cleanup some style issues pertaining to iterator invalidation
* Don't pass the Function pointer to the OptimizeCall function because if
  the optimization needs it, it can get it from the CallInst passed in.
* Add the skeleton for a new CallOptimizer, StrCatOptimizer which will
  eventually replace strcat's of constant strings with direct copies.

llvm-svn: 21526
2005-04-25 03:59:26 +00:00
Reid Spencer 23423346f8 Use the %name rather than the "name" format so those familiar with the
llvm-dis output don't go blind.

llvm-svn: 21525
2005-04-25 03:18:19 +00:00
Reid Spencer ff7b16c1d6 Shut GCC 4.0 up about classes that have virtual functions but a non-virtual
destructor. Just add the do-nothing virtual destructor.

llvm-svn: 21524
2005-04-25 02:55:55 +00:00
Reid Spencer 0c2d046aa4 Declare a function to create the SimplifyLibCalls pass.
llvm-svn: 21523
2005-04-25 02:54:00 +00:00
Reid Spencer 39a762d149 A new pass to provide specific optimizations for certain well-known library
calls. The pass visits all external functions in the module and determines
if such function calls can be optimized. The optimizations are specific to
the library calls involved. This initial version only optimizes calls to
exit(3) when they occur in main(): it changes them to ret instructions.

llvm-svn: 21522
2005-04-25 02:53:12 +00:00
Reid Spencer 985f484263 A test case for the the ExitInMain libcall simplification.
llvm-svn: 21521
2005-04-25 02:50:08 +00:00
Reid Spencer 8edc8beacf Older compilers won't like the inline virtual destructor in the header file
so we put the destructor in Pass.cpp and make it non-inline.

llvm-svn: 21520
2005-04-25 01:01:35 +00:00
Chris Lattner fc104de06d fix some bugs
llvm-svn: 21515
2005-04-25 00:38:52 +00:00
Reid Spencer 756d049c06 Fix a thinko in the documentation of the splitBasicBlock method. The branch
instruction is added to the original block, not the new block.

llvm-svn: 21513
2005-04-25 00:31:53 +00:00
Reid Spencer 9c47b25868 Shut GCC 4.0 up about classes with virtual functions but no virtual
destructor.

llvm-svn: 21510
2005-04-24 22:27:20 +00:00
Reid Spencer ad750a80eb Shut GCC 4.0 up when it complains about classes with virtual functions that
don't have virtual destructors.

llvm-svn: 21507
2005-04-24 22:20:32 +00:00
Reid Spencer 4da978466d Make this readable for newbies and those who can only understand one set of
grammar rules for the English language.

llvm-svn: 21503
2005-04-24 20:56:18 +00:00
Misha Brukman 6818b33096 extract has been renamed to llvm-extract to avoid conflicting with another tool
llvm-svn: 21501
2005-04-24 17:46:58 +00:00
Chris Lattner 2f1457fd83 Eliminate cases where we could << by 64, which is undefined in C.
llvm-svn: 21500
2005-04-24 17:46:05 +00:00
Misha Brukman ca1e0c6ae0 There are still uses for spaces in Makefiles -- to make text line up together,
regardless of the tab size/stop settings on the developer side

llvm-svn: 21499
2005-04-24 17:43:41 +00:00
Misha Brukman e22594f3d7 extract has been renamed to llvm-extract to avoid conflicting with another tool
llvm-svn: 21498
2005-04-24 17:36:05 +00:00
Misha Brukman 3e9634eaa0 elisp code to help with LLVM code standards compliance
llvm-svn: 21497
2005-04-24 17:09:19 +00:00
Misha Brukman 831ad84eea .vimrc file to aid in LLVM coding standards conformance
llvm-svn: 21496
2005-04-24 17:05:04 +00:00
Chris Lattner d6f636a340 Implement xor.ll:test21: select (not C), A, B -> select C, B, A
llvm-svn: 21495
2005-04-24 07:30:14 +00:00
Chris Lattner b57d040464 Test that xor/select are folded into a select with inverted operands.
llvm-svn: 21494
2005-04-24 07:28:53 +00:00
Chris Lattner 2c7d177d25 Allow these methods to take a generic Value* to simplify clients. Use
const_cast instead of c casts.

llvm-svn: 21493
2005-04-24 07:28:37 +00:00
Chris Lattner b220952aca allow these to take a generic Value*
llvm-svn: 21492
2005-04-24 07:28:04 +00:00
Chris Lattner d1f46d3bf9 Use getPrimitiveSizeInBits() instead of getPrimitiveSize()*8
Completely rework the 'setcc (cast x to larger), y' code.  This code has
the advantage of implementing setcc.ll:test19 (being more general than
the previous code) and being correct in all cases.

This allows us to unxfail 2004-11-27-SetCCForCastLargerAndConstant.ll,
and close PR454.

llvm-svn: 21491
2005-04-24 06:59:08 +00:00
Chris Lattner 0de0638522 unxfail this.
llvm-svn: 21490
2005-04-24 06:55:40 +00:00
Chris Lattner 624d5cb006 add a new testcase which occurs in 181.mcf
llvm-svn: 21489
2005-04-24 06:55:33 +00:00
Misha Brukman 1c8d93b08f * The aesthetic police is on patrol!!...
* ... but it wasn't so busy as to not smell the roses and doxygenify comments

llvm-svn: 21487
2005-04-23 22:35:26 +00:00
Chris Lattner 396890d3ac Add a helper method
llvm-svn: 21486
2005-04-23 22:20:22 +00:00
Chris Lattner 8a878ccb25 Fix a bug in my previous checkin
llvm-svn: 21485
2005-04-23 22:01:39 +00:00
Chris Lattner 2908bc1e7a This file is never referenced
llvm-svn: 21484
2005-04-23 22:00:26 +00:00
Chris Lattner 6263766133 Add a method, remove last use of Type.def
llvm-svn: 21483
2005-04-23 22:00:09 +00:00
Chris Lattner 816394d7ad add a method, remove a dead #include
llvm-svn: 21482
2005-04-23 21:59:42 +00:00
Chris Lattner 6226f941b0 Types.def is going away
llvm-svn: 21481
2005-04-23 21:59:11 +00:00
Jeff Cohen 82639853c0 Eliminate tabs and trailing spaces
llvm-svn: 21480
2005-04-23 21:38:35 +00:00
Jeff Cohen 8047f13a88 Eliminate tabs and trailing spaces
llvm-svn: 21479
2005-04-23 21:26:11 +00:00
Chris Lattner 4bbf66b7a2 Propagate eq sets through the bu graphs to the cbu and eq graphs, fixing
a crash of the sfv on 188.ammp

llvm-svn: 21478
2005-04-23 21:11:05 +00:00
Chris Lattner fdfb25a9e1 add a bunch of documentation about the LLVM type resolution machinery
llvm-svn: 21475
2005-04-23 17:27:36 +00:00
Reid Spencer 7fa89cfc9b Make the CBackend actually get included in llc by using USEDLIBS instead of
USEDLIB as the variable to which "CBackend" is appended. The surrounding
if clause is safe because currently the configure script ensures that the
CBackend target is always added to TARGETS_TO_BUILD. By using a non-hard
coded construct in the makefile, we gain uniformity and the ability to
change the default set of targets by only changing the configure script.

llvm-svn: 21474
2005-04-23 17:24:33 +00:00
Chris Lattner c6ce71d434 make an advanced topics section, move symtab to it
llvm-svn: 21473
2005-04-23 16:10:52 +00:00