llvm-6502/test
Chris Lattner 5d37370a6f When loop rotation happens, it is *very* common for the duplicated condbr
to be foldable into an uncond branch.  When this happens, we can make a
much simpler CFG for the loop, which is important for nested loop cases
where we want the outer loop to be aggressively optimized.

Handle this case more aggressively.  For example, previously on
phi-duplicate.ll we would get this:


define void @test(i32 %N, double* %G) nounwind ssp {
entry:
  %cmp1 = icmp slt i64 1, 1000
  br i1 %cmp1, label %bb.nph, label %for.end

bb.nph:                                           ; preds = %entry
  br label %for.body

for.body:                                         ; preds = %bb.nph, %for.cond
  %j.02 = phi i64 [ 1, %bb.nph ], [ %inc, %for.cond ]
  %arrayidx = getelementptr inbounds double* %G, i64 %j.02
  %tmp3 = load double* %arrayidx
  %sub = sub i64 %j.02, 1
  %arrayidx6 = getelementptr inbounds double* %G, i64 %sub
  %tmp7 = load double* %arrayidx6
  %add = fadd double %tmp3, %tmp7
  %arrayidx10 = getelementptr inbounds double* %G, i64 %j.02
  store double %add, double* %arrayidx10
  %inc = add nsw i64 %j.02, 1
  br label %for.cond

for.cond:                                         ; preds = %for.body
  %cmp = icmp slt i64 %inc, 1000
  br i1 %cmp, label %for.body, label %for.cond.for.end_crit_edge

for.cond.for.end_crit_edge:                       ; preds = %for.cond
  br label %for.end

for.end:                                          ; preds = %for.cond.for.end_crit_edge, %entry
  ret void
}

Now we get the much nicer:

define void @test(i32 %N, double* %G) nounwind ssp {
entry:
  br label %for.body

for.body:                                         ; preds = %entry, %for.body
  %j.01 = phi i64 [ 1, %entry ], [ %inc, %for.body ]
  %arrayidx = getelementptr inbounds double* %G, i64 %j.01
  %tmp3 = load double* %arrayidx
  %sub = sub i64 %j.01, 1
  %arrayidx6 = getelementptr inbounds double* %G, i64 %sub
  %tmp7 = load double* %arrayidx6
  %add = fadd double %tmp3, %tmp7
  %arrayidx10 = getelementptr inbounds double* %G, i64 %j.01
  store double %add, double* %arrayidx10
  %inc = add nsw i64 %j.01, 1
  %cmp = icmp slt i64 %inc, 1000
  br i1 %cmp, label %for.body, label %for.end

for.end:                                          ; preds = %for.body
  ret void
}

With all of these recent changes, we are now able to compile:

void foo(char *X) {
 for (int i = 0; i != 100; ++i) 
   for (int j = 0; j != 100; ++j)
     X[j+i*100] = 0;
}

into a single memset of 10000 bytes.  This series of changes
should also be helpful for other nested loop scenarios as well.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123079 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-08 19:59:06 +00:00
..
Analysis fix rdar://8813415 - a miscompilation of 164.gzip that loop-idiom 2011-01-03 21:03:33 +00:00
Archive Revert test/Archive/check_binary_output.ll". It fails on a buildbot. 2010-12-07 05:57:02 +00:00
Assembler First step in fixing PR8927: 2011-01-08 16:42:36 +00:00
Bindings/Ocaml XFAIL vg_leak the new test as the rest. 2010-12-23 21:22:09 +00:00
Bitcode Testcase for PR8494 (invalid bitcode crashing the bitcode reader). 2010-10-28 15:57:30 +00:00
BugPoint test: Check the feature 'loadable_module' with load modules in %llvmshlibdir. 2010-11-29 07:58:32 +00:00
CodeGen Recognize inline asm 'rev /bin/bash, ' as a bswap intrinsic call. 2011-01-08 01:24:27 +00:00
DebugInfo Hide tests, that check .loc, .file in output assembly, from darwin9 buildbot. 2010-12-02 23:29:58 +00:00
ExecutionEngine XFAIL for now. If someone with access to an ARM/Linux host wants to have a look 2010-12-02 20:20:32 +00:00
Feature test: Check the feature 'loadable_module' with load modules in %llvmshlibdir. 2010-11-29 07:58:32 +00:00
FrontendAda Adjust this test for the fact that the stores are no longer 2010-12-02 20:56:51 +00:00
FrontendC Test case for r120740. Radar 8712503. 2010-12-02 21:25:55 +00:00
FrontendC++ This test dates from the time when llvm-gcc had problems if two types were 2010-12-02 18:19:23 +00:00
FrontendFortran Use -S rather than -c for the benefit of dragonegg. 2010-11-25 21:41:35 +00:00
FrontendObjC Remove explicit uses of -emit-llvm, the test infrastructure adds it 2010-11-25 21:46:07 +00:00
FrontendObjC++ Remove explicit uses of -emit-llvm, the test infrastructure adds it 2010-11-25 21:48:20 +00:00
Integer we are past the point where these tests are useful. 2010-09-02 22:32:02 +00:00
lib Use LLVMCC_EMITIR_FLAG rather than hard-coding "-emit-llvm". 2010-11-25 21:19:52 +00:00
Linker Fix PR8300 by remembering to keep the bitcast in all cases. 2010-10-19 02:02:57 +00:00
LLVMC Remove -llvmc-temp-hack from tblgen. 2010-10-23 07:32:53 +00:00
MC Correctly disassemble truncated asm. 2011-01-06 16:48:42 +00:00
Other test/Other/close-stderr.ll: Require the feature 'shell'. It is not executable on Win32 but it is executable on MSYS-bash. 2010-12-07 02:43:58 +00:00
Scripts Print all 64bits for st_value and st_size. Adjust tests accordingly. 2010-12-20 20:49:43 +00:00
TableGen Rename lisp-like functions as suggested by Gabor Greif as loooong time 2011-01-07 17:05:37 +00:00
Transforms When loop rotation happens, it is *very* common for the duplicated condbr 2011-01-08 19:59:06 +00:00
Unit Test: Fix Support.Path and _all_ of the unittest death tests. GetTempPath defaults to \Windows\. 2010-12-07 01:23:49 +00:00
Verifier
CMakeLists.txt macho-dump: Fix CMake build, following up to r121466. 2010-12-10 09:18:26 +00:00
lit.cfg Fix lit for people whose LLVM path contains 'opt', which is a common directory name on Unix-like systems. 2011-01-05 15:10:24 +00:00
lit.site.cfg.in test: Add the new feature 'loadable_module'. 2010-11-29 00:20:09 +00:00
Makefile test: Use $SharedLibDir for loadable modules. On Cygming, loadable modules are not in lib/ but bin. 2010-11-29 00:20:21 +00:00
Makefile.tests
site.exp.in test: Use $SharedLibDir for loadable modules. On Cygming, loadable modules are not in lib/ but bin. 2010-11-29 00:20:21 +00:00
TestRunner.sh Use exec. 2010-08-29 14:49:00 +00:00