blob: c18af5e07efdd8c119b043f2743564ebdcdc29ef [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001; With sub reassociation, constant folding can eliminate all of the constants.
2;
Dan Gohman3c7d3082009-09-11 18:01:28 +00003; RUN: opt < %s -reassociate -constprop -instcombine -dce -S | not grep add
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004
Tanya Lattner028031a2008-03-19 04:36:04 +00005define i32 @test(i32 %A, i32 %B) {
6 %W = add i32 5, %B ; <i32> [#uses=1]
7 %X = add i32 -7, %A ; <i32> [#uses=1]
8 %Y = sub i32 %X, %W ; <i32> [#uses=1]
9 %Z = add i32 %Y, 12 ; <i32> [#uses=1]
10 ret i32 %Z
Dan Gohmanf17a25c2007-07-18 16:29:46 +000011}
Tanya Lattner028031a2008-03-19 04:36:04 +000012