blob: 78bd0ef3b8aa290366a859efd2761ecf7e63c778 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001; With sub reassociation, constant folding can eliminate the 12 and -12 constants.
2;
Dan Gohman1b4c27772009-09-08 16:50:01 +00003; RUN: opt %s -reassociate -instcombine | llvm-dis | not grep 12
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004
Chris Lattnere0afcf22008-02-17 20:48:43 +00005define i32 @test(i32 %A, i32 %B) {
6 %X = add i32 -12, %A ; <i32> [#uses=1]
7 %Y = sub i32 %X, %B ; <i32> [#uses=1]
8 %Z = add i32 %Y, 12 ; <i32> [#uses=1]
9 ret i32 %Z
Dan Gohmanf17a25c2007-07-18 16:29:46 +000010}
Chris Lattnere0afcf22008-02-17 20:48:43 +000011