1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=reassociate,early-cse -earlycse-debug-hash -S < %s | FileCheck %s
4 @num1 = local_unnamed_addr global i32 0, align 4
5 @num2 = local_unnamed_addr global i32 0, align 4
6 @num3 = local_unnamed_addr global i32 0, align 4
7 @num4 = local_unnamed_addr global i32 0, align 4
9 define signext i32 @twoPairs(i32 signext %0, i32 signext %1, i32 signext %2, i32 signext %3, i32 signext %4) {
10 ; CHECK-LABEL: @twoPairs(
11 ; CHECK-NEXT: [[TMP6:%.*]] = add i32 [[TMP2:%.*]], [[TMP0:%.*]]
12 ; CHECK-NEXT: [[TMP7:%.*]] = add i32 [[TMP6]], [[TMP1:%.*]]
13 ; CHECK-NEXT: [[TMP8:%.*]] = add i32 [[TMP7]], [[TMP3:%.*]]
14 ; CHECK-NEXT: [[TMP9:%.*]] = add i32 [[TMP8]], [[TMP4:%.*]]
15 ; CHECK-NEXT: store i32 [[TMP9]], ptr @num1, align 4
16 ; CHECK-NEXT: store i32 [[TMP6]], ptr @num2, align 4
17 ; CHECK-NEXT: [[TMP10:%.*]] = add nsw i32 [[TMP3]], [[TMP1]]
18 ; CHECK-NEXT: store i32 [[TMP10]], ptr @num3, align 4
19 ; CHECK-NEXT: ret i32 undef
25 store i32 %9, ptr @num1, align 4
26 %10 = add nsw i32 %2, %0
27 store i32 %10, ptr @num2, align 4
28 %11 = add nsw i32 %3, %1
29 store i32 %11, ptr @num3, align 4
33 define signext i32 @twoPairsAllOpInPairs(i32 signext %0, i32 signext %1, i32 signext %2, i32 signext %3) {
34 ; CHECK-LABEL: @twoPairsAllOpInPairs(
35 ; CHECK-NEXT: [[TMP5:%.*]] = add i32 [[TMP2:%.*]], [[TMP1:%.*]]
36 ; CHECK-NEXT: [[TMP6:%.*]] = add i32 [[TMP5]], [[TMP0:%.*]]
37 ; CHECK-NEXT: [[TMP7:%.*]] = add nsw i32 [[TMP6]], [[TMP3:%.*]]
38 ; CHECK-NEXT: store i32 [[TMP7]], ptr @num1, align 4
39 ; CHECK-NEXT: store i32 [[TMP5]], ptr @num2, align 4
40 ; CHECK-NEXT: [[TMP8:%.*]] = add nsw i32 [[TMP3]], [[TMP0]]
41 ; CHECK-NEXT: store i32 [[TMP8]], ptr @num3, align 4
42 ; CHECK-NEXT: ret i32 undef
44 %5 = add nsw i32 %0, %1
45 %6 = add nsw i32 %5, %2
46 %7 = add nsw i32 %6, %3
47 store i32 %7, ptr @num1, align 4
48 %8 = add nsw i32 %1, %2
49 store i32 %8, ptr @num2, align 4
50 %9 = add nsw i32 %0, %3
51 store i32 %9, ptr @num3, align 4
55 define signext i32 @threePairsAllOpInPairs(i32 signext %0, i32 signext %1, i32 signext %2, i32 signext %3, i32 signext %4, i32 signext %5) {
56 ; CHECK-LABEL: @threePairsAllOpInPairs(
57 ; CHECK-NEXT: [[TMP7:%.*]] = add i32 [[TMP3:%.*]], [[TMP2:%.*]]
58 ; CHECK-NEXT: [[TMP8:%.*]] = add i32 [[TMP7]], [[TMP0:%.*]]
59 ; CHECK-NEXT: [[TMP9:%.*]] = add i32 [[TMP8]], [[TMP1:%.*]]
60 ; CHECK-NEXT: [[TMP10:%.*]] = add nsw i32 [[TMP9]], [[TMP4:%.*]]
61 ; CHECK-NEXT: [[TMP11:%.*]] = add nsw i32 [[TMP10]], [[TMP5:%.*]]
62 ; CHECK-NEXT: store i32 [[TMP11]], ptr @num1, align 4
63 ; CHECK-NEXT: [[TMP12:%.*]] = add nsw i32 [[TMP5]], [[TMP0]]
64 ; CHECK-NEXT: store i32 [[TMP12]], ptr @num2, align 4
65 ; CHECK-NEXT: [[TMP13:%.*]] = add nsw i32 [[TMP4]], [[TMP1]]
66 ; CHECK-NEXT: store i32 [[TMP13]], ptr @num3, align 4
67 ; CHECK-NEXT: store i32 [[TMP7]], ptr @num4, align 4
68 ; CHECK-NEXT: ret i32 undef
70 %7 = add nsw i32 %0, %1
71 %8 = add nsw i32 %7, %2
72 %9 = add nsw i32 %8, %3
73 %10 = add nsw i32 %9, %4
74 %11 = add nsw i32 %10, %5
75 store i32 %11, ptr @num1, align 4
76 %12 = add nsw i32 %0, %5
77 store i32 %12, ptr @num2, align 4
78 %13 = add nsw i32 %1, %4
79 store i32 %13, ptr @num3, align 4
80 %14 = add nsw i32 %2, %3
81 store i32 %14, ptr @num4, align 4