--TEST-- 007: GCM for simple loop (Figure 7 from "Global Code Motion Global Value Numbering" by Cliff Click) --ARGS-- --dump-gcm --save --dump-after-gcm --CODE-- { uintptr_t c_1 = 0; bool c_2 = 0; bool c_3 = 1; int32_t c_4 = 10; int32_t c_5 = 2; int32_t c_6 = 1; int32_t c_7 = 0; l_1 = START(l_16); int32_t d_2 = PARAM(l_1, "x", 0); l_3 = END(l_1); l_4 = LOOP_BEGIN(l_3, l_12); int32_t d_5 = PHI(l_4, c_7, d_7); int32_t d_6 = ADD(d_2, c_6); int32_t d_7 = ADD(d_6, d_5); int32_t d_8 = MUL(d_7, c_5); bool d_9 = LT(d_7, c_4); l_10 = IF(l_4, d_9); l_11 = IF_TRUE(l_10); l_12 = LOOP_END(l_11, l_4); l_13 = IF_FALSE(l_10); l_14 = LOOP_EXIT(l_13, l_4); l_15 = BEGIN(l_14); l_16 = RETURN(l_15, d_8); } --EXPECT-- { uintptr_t c_1 = 0; bool c_2 = 0; bool c_3 = 1; int32_t c_4 = 10; int32_t c_5 = 2; int32_t c_6 = 1; int32_t c_7 = 0; l_1 = START(l_16); int32_t d_2 = PARAM(l_1, "x", 0); l_3 = END(l_1); l_4 = LOOP_BEGIN(l_3, l_12); int32_t d_5 = PHI(l_4, c_7, d_7); int32_t d_6 = ADD(d_2, c_6); int32_t d_7 = ADD(d_6, d_5); int32_t d_8 = ADD(d_7, d_7); bool d_9 = LT(d_7, c_4); l_10 = IF(l_4, d_9); l_11 = IF_TRUE(l_10); l_12 = LOOP_END(l_11, l_4); l_13 = IF_FALSE(l_10); l_14 = LOOP_EXIT(l_13, l_4); l_15 = BEGIN(l_14); l_16 = RETURN(l_15, d_8); } { # GCM 1 -> 1 2 -> 1 3 -> 1 4 -> 2 5 -> 2 6 -> 1 7 -> 2 8 -> 5 9 -> 2 10 -> 2 11 -> 3 12 -> 3 13 -> 4 14 -> 4 15 -> 5 16 -> 5 }