blob: 5848821e10fdcfbf4621d95188374099da9df29f [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001; With sub reassociation, constant folding can eliminate the two 12 constants.
2;
Dan Gohman3c7d3082009-09-11 18:01:28 +00003; RUN: opt < %s -reassociate -constprop -dce -S | not grep 12
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004
Tanya Lattner028031a2008-03-19 04:36:04 +00005define i32 @test(i32 %A, i32 %B, i32 %C, i32 %D) {
6 %M = add i32 %A, 12 ; <i32> [#uses=1]
7 %N = add i32 %M, %B ; <i32> [#uses=1]
8 %O = add i32 %N, %C ; <i32> [#uses=1]
9 %P = sub i32 %D, %O ; <i32> [#uses=1]
10 %Q = add i32 %P, 12 ; <i32> [#uses=1]
11 ret i32 %Q
Dan Gohmanf17a25c2007-07-18 16:29:46 +000012}
Tanya Lattner028031a2008-03-19 04:36:04 +000013