1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -reassociate -S | FileCheck %s
4 ; Input is A op (B op C)
6 define half @faddsubAssoc1(half %a, half %b) {
7 ; CHECK-LABEL: @faddsubAssoc1(
8 ; CHECK-NEXT: [[T2_NEG:%.*]] = fmul fast half [[A:%.*]], 0xH4500
9 ; CHECK-NEXT: [[REASS_MUL:%.*]] = fmul fast half [[B:%.*]], 0xH4500
10 ; CHECK-NEXT: [[T51:%.*]] = fsub fast half [[REASS_MUL]], [[T2_NEG]]
11 ; CHECK-NEXT: [[T5:%.*]] = fadd fast half [[REASS_MUL]], [[T2_NEG]]
12 ; CHECK-NEXT: ret half [[T51]]
14 %t1 = fmul fast half %b, 0xH4200 ; 3*b
15 %t2 = fmul fast half %a, 0xH4500 ; 5*a
16 %t3 = fmul fast half %b, 0xH4000 ; 2*b
17 %t4 = fsub fast half %t2, %t1 ; 5 * a - 3 * b
18 %t5 = fsub fast half %t3, %t4 ; 2 * b - ( 5 * a - 3 * b)
19 ret half %t5 ; = 5 * (b - a)
22 ; Input is (A op B) op C
24 define half @faddsubAssoc2(half %a, half %b) {
25 ; CHECK-LABEL: @faddsubAssoc2(
26 ; CHECK-NEXT: [[T2:%.*]] = fmul fast half [[A:%.*]], 0xH4500
27 ; CHECK-NEXT: [[T5:%.*]] = fadd fast half [[B:%.*]], [[T2]]
28 ; CHECK-NEXT: ret half [[T5]]
30 %t1 = fmul fast half %b, 0xH4200 ; 3*b
31 %t2 = fmul fast half %a, 0xH4500 ; 5*a
32 %t3 = fmul fast half %b, 0xH4000 ; 2*b
33 %t4 = fadd fast half %t2, %t1 ; 5 * a + 3 * b
34 %t5 = fsub fast half %t4, %t3 ; (5 * a + 3 * b) - (2 * b)
35 ret half %t5 ; = 5 * a + b