On Tue, Mar 24, 2009 at 10:09 PM, Chris Lattner <span dir="ltr"><<a href="mailto:clattner@apple.com">clattner@apple.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div style=""><div><div class="h5"><div><div>On Mar 24, 2009, at 2:45 PM, Misha Brukman wrote:</div><br><blockquote type="cite">On Tue, Mar 24, 2009 at 2:15 PM, Chris Lattner <span dir="ltr"><<a href="mailto:sabre@nondot.org" target="_blank">sabre@nondot.org</a>></span> wrote:<br>
<div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> ==============================================================================<br>
 --- llvm/trunk/test/Transforms/InstCombine/shift.ll (original)<br> +++ llvm/trunk/test/Transforms/InstCombine/shift.ll Tue Mar 24 13:15:30 2009<br> @@ -206,4 +206,11 @@<br>         %D = shl i32 %C, 1              ; <i32> [#uses=1]<br>
         ret i32 %D<br>  }<br> +<br> +<br> +define i1 @test27(i32 %x) nounwind {<br> +  %y = lshr i32 %x, 3<br> +  %z = trunc i32 %y to i1<br> +  ret i1 %z<br> +}</blockquote><div><br>This would work great as a unittest.  Just sayin'.<br>
</div></div></blockquote></div></div></div><div>Why would it be better as a unit test?</div></div></blockquote><div><br>shift.ll has this RUN line:<br> ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep sh<br>
</div></div>which means that all -instcombine needs to do is to delete any shift-related instructions and it would still pass.  This test is not checking that -instcombine is replacing each shift instruction with the proper sequence of instructions, which you cannot do with grep.  Also, to test this .ll file, it requires
loading and running 5 executables (llvm-{as,dis}, opt, grep, and bash
for "not"), and parsing/unparsing LLVM assembly and bytecode, the
latter of which are orthogonal to the thing being tested, but still take time.  The test suite then does this over and over for each .ll file being tested.<br><br>To improve the test you *could* replace the "not grep sh" with a diff
to a "golden file" that has all the expected
code sequences, but I would argue that
we can make the tests run faster by avoiding all the extra binary invocations (and in the latter
case, also writing to a file on disk and calling diff on the two) and just
write a unittest instead.<br><br>Misha<br>