1 ; RUN: opt < %s -passes=reassociate,instcombine -S | FileCheck %s
3 ; With sub reassociation, constant folding can eliminate the 12 and -12 constants.
4 define i32 @test1(i32 %A, i32 %B) {
6 ; CHECK-NEXT: [[Z:%.*]] = sub i32 %A, %B
7 ; CHECK-NEXT: ret i32 [[Z]]
16 ; With sub reassociation, constant folding can eliminate the uses of %a.
17 define i32 @test2(i32 %a, i32 %b, i32 %c) {
18 ; CHECK-LABEL: @test2(
19 ; CHECK-NEXT: [[SUM:%.*]] = add i32 %c, %b
20 ; CHECK-NEXT: [[TMP7:%.*]] = sub i32 0, [[SUM]]
21 ; CHECK-NEXT: ret i32 [[TMP7]]
23 %tmp3 = sub i32 %a, %b
24 %tmp5 = sub i32 %tmp3, %c
25 %tmp7 = sub i32 %tmp5, %a