1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt -reassociate -early-cse -earlycse-debug-hash -S < %s | FileCheck %s 3 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 8 9define 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]], i32* @num1, align 4 16; CHECK-NEXT: store i32 [[TMP6]], i32* @num2, align 4 17; CHECK-NEXT: [[TMP10:%.*]] = add nsw i32 [[TMP3]], [[TMP1]] 18; CHECK-NEXT: store i32 [[TMP10]], i32* @num3, align 4 19; CHECK-NEXT: ret i32 undef 20; 21 %6 = add i32 %2, %0 22 %7 = add i32 %6, %1 23 %8 = add i32 %7, %3 24 %9 = add i32 %8, %4 25 store i32 %9, i32* @num1, align 4 26 %10 = add nsw i32 %2, %0 27 store i32 %10, i32* @num2, align 4 28 %11 = add nsw i32 %3, %1 29 store i32 %11, i32* @num3, align 4 30 ret i32 undef 31} 32 33define 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 i32 [[TMP6]], [[TMP3:%.*]] 38; CHECK-NEXT: store i32 [[TMP7]], i32* @num1, align 4 39; CHECK-NEXT: store i32 [[TMP5]], i32* @num2, align 4 40; CHECK-NEXT: [[TMP8:%.*]] = add nsw i32 [[TMP3]], [[TMP0]] 41; CHECK-NEXT: store i32 [[TMP8]], i32* @num3, align 4 42; CHECK-NEXT: ret i32 undef 43; 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, i32* @num1, align 4 48 %8 = add nsw i32 %1, %2 49 store i32 %8, i32* @num2, align 4 50 %9 = add nsw i32 %0, %3 51 store i32 %9, i32* @num3, align 4 52 ret i32 undef 53} 54 55define 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 i32 [[TMP9]], [[TMP4:%.*]] 61; CHECK-NEXT: [[TMP11:%.*]] = add i32 [[TMP10]], [[TMP5:%.*]] 62; CHECK-NEXT: store i32 [[TMP11]], i32* @num1, align 4 63; CHECK-NEXT: [[TMP12:%.*]] = add nsw i32 [[TMP5]], [[TMP0]] 64; CHECK-NEXT: store i32 [[TMP12]], i32* @num2, align 4 65; CHECK-NEXT: [[TMP13:%.*]] = add nsw i32 [[TMP4]], [[TMP1]] 66; CHECK-NEXT: store i32 [[TMP13]], i32* @num3, align 4 67; CHECK-NEXT: store i32 [[TMP7]], i32* @num4, align 4 68; CHECK-NEXT: ret i32 undef 69; 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, i32* @num1, align 4 76 %12 = add nsw i32 %0, %5 77 store i32 %12, i32* @num2, align 4 78 %13 = add nsw i32 %1, %4 79 store i32 %13, i32* @num3, align 4 80 %14 = add nsw i32 %2, %3 81 store i32 %14, i32* @num4, align 4 82 ret i32 undef 83} 84