File: reassoc-intermediate-fnegs.ll

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (37 lines) | stat: -rw-r--r-- 1,270 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -passes=reassociate -S | FileCheck %s

; B * 5 + A * -5
; TODO: (B - A) * 5

define half @faddsubAssoc1(half %a, half %b) {
; CHECK-LABEL: @faddsubAssoc1(
; CHECK-NEXT:    [[T2_NEG:%.*]] = fmul fast half [[A:%.*]], 0xHC500
; CHECK-NEXT:    [[REASS_MUL:%.*]] = fmul fast half [[B:%.*]], 0xH4500
; CHECK-NEXT:    [[T5:%.*]] = fadd fast half [[REASS_MUL]], [[T2_NEG]]
; CHECK-NEXT:    ret half [[T5]]
;
  %t1 = fmul fast half %b, 0xH4200 ; 3*b
  %t2 = fmul fast half %a, 0xH4500 ; 5*a
  %t3 = fmul fast half %b, 0xH4000 ; 2*b
  %t4 = fsub fast half %t2, %t1 ; 5 * a - 3 * b
  %t5 = fsub fast half %t3, %t4 ; 2 * b - ( 5 * a - 3 * b)
  ret half %t5 ; = 5 * (b - a)
}

; B + A * 5

define half @faddsubAssoc2(half %a, half %b) {
; CHECK-LABEL: @faddsubAssoc2(
; CHECK-NEXT:    [[T2:%.*]] = fmul fast half [[A:%.*]], 0xH4500
; CHECK-NEXT:    [[T5:%.*]] = fadd fast half [[B:%.*]], [[T2]]
; CHECK-NEXT:    ret half [[T5]]
;
  %t1 = fmul fast half %b, 0xH4200 ; 3*b
  %t2 = fmul fast half %a, 0xH4500 ; 5*a
  %t3 = fmul fast half %b, 0xH4000 ; 2*b
  %t4 = fadd fast half %t2, %t1 ; 5 * a + 3 * b
  %t5 = fsub fast half %t4, %t3 ; (5 * a + 3 * b) - (2 * b)
  ret half %t5 ; = 5 * a + b
}