1; RUN: opt < %s -reassociate -S | FileCheck %s 2; CHECK-LABEL: faddsubAssoc1 3; CHECK: [[TMP1:%.*]] = fsub fast half 0xH8000, %a 4; CHECK: [[TMP2:%.*]] = fadd fast half %b, [[TMP1]] 5; CHECK: fmul fast half [[TMP2]], 0xH4500 6; CHECK: ret 7; Input is A op (B op C) 8define half @faddsubAssoc1(half %a, half %b) { 9 %tmp1 = fmul fast half %b, 0xH4200 ; 3*b 10 %tmp2 = fmul fast half %a, 0xH4500 ; 5*a 11 %tmp3 = fmul fast half %b, 0xH4000 ; 2*b 12 %tmp4 = fsub fast half %tmp2, %tmp1 ; 5 * a - 3 * b 13 %tmp5 = fsub fast half %tmp3, %tmp4 ; 2 * b - ( 5 * a - 3 * b) 14 ret half %tmp5 ; = 5 * (b - a) 15} 16 17; CHECK-LABEL: faddsubAssoc2 18; CHECK: [[TMP1:%tmp.*]] = fmul fast half %a, 0xH4500 19; CHECK: [[TMP2:%tmp.*]] = fmul fast half %b, 0xH3C00 20; CHECK: fadd fast half [[TMP2]], [[TMP1]] 21; CHECK: ret 22; Input is (A op B) op C 23define half @faddsubAssoc2(half %a, half %b) { 24 %tmp1 = fmul fast half %b, 0xH4200 ; 3*b 25 %tmp2 = fmul fast half %a, 0xH4500 ; 5*a 26 %tmp3 = fmul fast half %b, 0xH4000 ; 2*b 27 %tmp4 = fadd fast half %tmp2, %tmp1 ; 5 * a + 3 * b 28 %tmp5 = fsub fast half %tmp4, %tmp3 ; (5 * a + 3 * b) - (2 * b) 29 ret half %tmp5 ; = 5 * a + b 30} 31 32