1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -reassociate -constprop -instcombine -dce -S | FileCheck %s
4 ; With sub reassociation, constant folding can eliminate all of the constants.
5 define i32 @test1(i32 %A, i32 %B) {
7 ; CHECK-NEXT: [[Z:%.*]] = sub i32 [[A:%.*]], [[B:%.*]]
8 ; CHECK-NEXT: ret i32 [[Z]]
17 ; With sub reassociation, constant folding can eliminate the two 12 constants.
18 define i32 @test2(i32 %A, i32 %B, i32 %C, i32 %D) {
19 ; CHECK-LABEL: @test2(
20 ; CHECK-NEXT: [[TMP1:%.*]] = add i32 [[B:%.*]], [[A:%.*]]
21 ; CHECK-NEXT: [[TMP2:%.*]] = add i32 [[TMP1]], [[C:%.*]]
22 ; CHECK-NEXT: [[Q:%.*]] = sub i32 [[D:%.*]], [[TMP2]]
23 ; CHECK-NEXT: ret i32 [[Q]]