From 44f87aca32be07fe3c8dfc1a0bbb178554d1e7d6 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 8 May 2002 22:20:55 +0000 Subject: [PATCH] New testcase for LICM reassociation git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2560 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Transforms/Reassociate/looptest.ll | 59 +++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 test/Transforms/Reassociate/looptest.ll diff --git a/test/Transforms/Reassociate/looptest.ll b/test/Transforms/Reassociate/looptest.ll new file mode 100644 index 00000000000..af516c6296b --- /dev/null +++ b/test/Transforms/Reassociate/looptest.ll @@ -0,0 +1,59 @@ +; This testcase comes from this C fragment: +; +; void test(unsigned Num, int *Array) { +; unsigned i, j, k; +; +; for (i = 0; i != Num; ++i) +; for (j = 0; j != Num; ++j) +; for (k = 0; k != Num; ++k) +; printf("%d\n", i+k+j); /* Reassociate to (i+j)+k */ +;} +; +; In this case, we want to reassociate the specified expr so that i+j can be +; hoisted out of the inner most loop. +; +; RUN: if as < %s | opt -reassociate | dis | grep 115 | grep 117 +; RUN: then exit 1 +; RUN: else exit 0 +; RUN: fi + +%.LC0 = internal global [4 x sbyte] c"%d\0A\00" ; <[4 x sbyte]*> [#uses=1] + +declare int "printf"(sbyte*, ...) + +void "test"(uint %Num, int* %Array) { +bb0: ;[#uses=1] + %cond221 = seteq uint 0, %Num ; [#uses=3] + br bool %cond221, label %bb7, label %bb2 + +bb2: ;[#uses=3] + %reg115 = phi uint [ %reg120, %bb6 ], [ 0, %bb0 ] ; [#uses=2] + br bool %cond221, label %bb6, label %bb3 + +bb3: ;[#uses=3] + %reg116 = phi uint [ %reg119, %bb5 ], [ 0, %bb2 ] ; [#uses=2] + br bool %cond221, label %bb5, label %bb4 + +bb4: ;[#uses=3] + %reg117 = phi uint [ %reg118, %bb4 ], [ 0, %bb3 ] ; [#uses=2] + %reg113 = add uint %reg115, %reg117 ; [#uses=1] + %reg114 = add uint %reg113, %reg116 ; [#uses=1] + %cast227 = getelementptr [4 x sbyte]* %.LC0, uint 0, uint 0 ; [#uses=1] + call int (sbyte*, ...)* %printf( sbyte* %cast227, uint %reg114 ) ; :0 [#uses=0] + %reg118 = add uint %reg117, 1 ; [#uses=2] + %cond224 = setne uint %reg118, %Num ; [#uses=1] + br bool %cond224, label %bb4, label %bb5 + +bb5: ;[#uses=3] + %reg119 = add uint %reg116, 1 ; [#uses=2] + %cond225 = setne uint %reg119, %Num ; [#uses=1] + br bool %cond225, label %bb3, label %bb6 + +bb6: ;[#uses=3] + %reg120 = add uint %reg115, 1 ; [#uses=2] + %cond226 = setne uint %reg120, %Num ; [#uses=1] + br bool %cond226, label %bb2, label %bb7 + +bb7: ;[#uses=2] + ret void +}