1 # RUN: llc -run-pass=machine-combiner -mtriple=aarch64-unknown-linux-gnu %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-SAFE
2 # RUN: llc -run-pass=machine-combiner -mtriple=aarch64-unknown-linux-gnu -enable-unsafe-fp-math %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-UNSAFE
4 # fadd without the reassoc flags can be reassociate only when unsafe fp math is
6 # CHECK-LABEL: name: fadd_no_reassoc
7 # CHECK: [[ADD1:%[0-9]+]]:fpr32 = FADDSrr %0, %1, implicit $fpcr
8 # CHECK-SAFE-NEXT: [[ADD2:%[0-9]+]]:fpr32 = FADDSrr killed [[ADD1]], %2, implicit $fpcr
9 # CHECK-SAFE-NEXT: [[ADD3:%[0-9]+]]:fpr32 = FADDSrr killed [[ADD2]], %3, implicit $fpcr
10 # CHECK-UNSAFE-NEXT: [[ADD2:%[0-9]+]]:fpr32 = FADDSrr %2, %3, implicit $fpcr
11 # CHECK-UNSAFE-NEXT: [[ADD3:%[0-9]+]]:fpr32 = FADDSrr killed [[ADD1]], killed [[ADD2]], implicit $fpcr
15 tracksRegLiveness: true
17 - { id: 0, class: fpr32 }
18 - { id: 1, class: fpr32 }
19 - { id: 2, class: fpr32 }
20 - { id: 3, class: fpr32 }
21 - { id: 4, class: fpr32 }
22 - { id: 5, class: fpr32 }
23 - { id: 6, class: fpr32 }
25 - { reg: '$s0', virtual-reg: '%0' }
26 - { reg: '$s1', virtual-reg: '%1' }
27 - { reg: '$s2', virtual-reg: '%2' }
28 - { reg: '$s3', virtual-reg: '%3' }
32 machineFunctionInfo: {}
35 liveins: $s0, $s1, $s2, $s3
41 %4:fpr32 = FADDSrr %0, %1, implicit $fpcr
42 %5:fpr32 = FADDSrr killed %4, %2, implicit $fpcr
43 %6:fpr32 = FADDSrr killed %5, %3, implicit $fpcr
45 RET_ReallyLR implicit $s0
48 # FIXME: We should be able to reassociate without unsafe fp math, but currently
49 # the reassoc flag is ignored.
50 # CHECK-LABEL: name: fadd_reassoc
51 # CHECK: [[ADD1:%[0-9]+]]:fpr32 = reassoc FADDSrr %0, %1, implicit $fpcr
52 # CHECK-SAFE-NEXT: [[ADD2:%[0-9]+]]:fpr32 = reassoc FADDSrr killed [[ADD1]], %2, implicit $fpcr
53 # CHECK-SAFE-NEXT: [[ADD3:%[0-9]+]]:fpr32 = reassoc FADDSrr killed [[ADD2]], %3, implicit $fpcr
54 # CHECK-UNSAFE-NEXT: [[ADD2:%[0-9]+]]:fpr32 = reassoc FADDSrr %2, %3, implicit $fpcr
55 # CHECK-UNSAFE-NEXT: [[ADD3:%[0-9]+]]:fpr32 = reassoc FADDSrr killed [[ADD1]], killed [[ADD2]], implicit $fpcr
59 tracksRegLiveness: true
61 - { id: 0, class: fpr32 }
62 - { id: 1, class: fpr32 }
63 - { id: 2, class: fpr32 }
64 - { id: 3, class: fpr32 }
65 - { id: 4, class: fpr32 }
66 - { id: 5, class: fpr32 }
67 - { id: 6, class: fpr32 }
69 - { reg: '$s0', virtual-reg: '%0' }
70 - { reg: '$s1', virtual-reg: '%1' }
71 - { reg: '$s2', virtual-reg: '%2' }
72 - { reg: '$s3', virtual-reg: '%3' }
76 machineFunctionInfo: {}
79 liveins: $s0, $s1, $s2, $s3
85 %4:fpr32 = reassoc FADDSrr %0, %1, implicit $fpcr
86 %5:fpr32 = reassoc FADDSrr killed %4, %2, implicit $fpcr
87 %6:fpr32 = reassoc FADDSrr killed %5, %3, implicit $fpcr
89 RET_ReallyLR implicit $s0
92 # Check that flags on the instructions are preserved after reassociation.
93 # CHECK-LABEL: name: fadd_flags
94 # CHECK: [[ADD1:%[0-9]+]]:fpr32 = nnan ninf nsz FADDSrr %0, %1, implicit $fpcr
95 # CHECK-SAFE-NEXT: [[ADD2:%[0-9]+]]:fpr32 = nnan nsz FADDSrr killed [[ADD1]], %2, implicit $fpcr
96 # CHECK-SAFE-NEXT: [[ADD3:%[0-9]+]]:fpr32 = ninf nsz FADDSrr killed [[ADD2]], %3, implicit $fpcr
97 # CHECK-UNSAFE-NEXT: [[ADD2:%[0-9]+]]:fpr32 = nsz FADDSrr %2, %3, implicit $fpcr
98 # CHECK-UNSAFE-NEXT: [[ADD3:%[0-9]+]]:fpr32 = nsz FADDSrr killed [[ADD1]], killed [[ADD2]], implicit $fpcr
102 tracksRegLiveness: true
104 - { id: 0, class: fpr32 }
105 - { id: 1, class: fpr32 }
106 - { id: 2, class: fpr32 }
107 - { id: 3, class: fpr32 }
108 - { id: 4, class: fpr32 }
109 - { id: 5, class: fpr32 }
110 - { id: 6, class: fpr32 }
112 - { reg: '$s0', virtual-reg: '%0' }
113 - { reg: '$s1', virtual-reg: '%1' }
114 - { reg: '$s2', virtual-reg: '%2' }
115 - { reg: '$s3', virtual-reg: '%3' }
119 machineFunctionInfo: {}
122 liveins: $s0, $s1, $s2, $s3
128 %4:fpr32 = nsz nnan ninf FADDSrr %0, %1, implicit $fpcr
129 %5:fpr32 = nsz nnan FADDSrr killed %4, %2, implicit $fpcr
130 %6:fpr32 = nsz ninf FADDSrr killed %5, %3, implicit $fpcr
132 RET_ReallyLR implicit $s0