1 ; RUN: opt < %s -reassociate -constprop -instcombine -dce -S | FileCheck %s
3 ; With sub reassociation, constant folding can eliminate all of the 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 two 12 constants.
17 define i32 @test2(i32 %A, i32 %B, i32 %C, i32 %D) {
18 ; CHECK-LABEL: @test2(
19 ; CHECK-NEXT: [[SUM:%.*]] = add i32 %B, %A
20 ; CHECK-NEXT: [[SUM1:%.*]] = add i32 [[SUM]], %C
21 ; CHECK-NEXT: [[Q:%.*]] = sub i32 %D, [[SUM1]]
22 ; CHECK-NEXT: ret i32 [[Q]]