blob: 513984e7722d4f601d6bdf2156c74ecd221b99cb [file] [log] [blame]
Chris Lattner11d13fb2002-05-15 20:30:48 +00001; With sub reassociation, constant folding can eliminate the 12 and -12 constants.
2;
Chris Lattnerf06c3c22008-02-17 20:48:43 +00003; RUN: llvm-as < %s | opt -reassociate -instcombine | llvm-dis | not grep 12
Chris Lattner11d13fb2002-05-15 20:30:48 +00004
Chris Lattnerf06c3c22008-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
Chris Lattner11d13fb2002-05-15 20:30:48 +000010}
Chris Lattnerf06c3c22008-02-17 20:48:43 +000011