blob: c34331cb8ced52658eabfaf7734996a03c724f1c [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001; With sub reassociation, constant folding can eliminate all of the constants.
2;
Dan Gohman5bb7c7c2009-09-08 22:34:10 +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