Skip to content

Commit 09aa896

Browse files
committed
Update tests for constraint intrinsics on PowerPC, RISCV, SystemZ, ARM
1 parent 7761f4d commit 09aa896

File tree

4 files changed

+524
-0
lines changed

4 files changed

+524
-0
lines changed

llvm/test/CodeGen/ARM/fp-intrinsics.ll

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,13 @@ define float @tan_f32(float %x) #0 {
146146
ret float %val
147147
}
148148

149+
; CHECK-LABEL: atan2_f32:
150+
; CHECK: bl atan2f
151+
define float @atan2_f32(float %x, float %y) #0 {
152+
%val = call float @llvm.experimental.constrained.atan2.f32(float %x, float %y, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
153+
ret float %val
154+
}
155+
149156
; CHECK-LABEL: pow_f32:
150157
; CHECK: bl powf
151158
define float @pow_f32(float %x, float %y) #0 {
@@ -610,6 +617,13 @@ define double @tan_f64(double %x) #0 {
610617
ret double %val
611618
}
612619

620+
; CHECK-LABEL: atan2_f64:
621+
; CHECK: bl atan2
622+
define double @atan2_f64(double %x, double %y) #0 {
623+
%val = call double @llvm.experimental.constrained.atan2.f64(double %x, double %y, metadata !"round.tonearest", metadata !"fpexcept.strict") #0
624+
ret double %val
625+
}
626+
613627
; CHECK-LABEL: pow_f64:
614628
; CHECK: bl pow
615629
define double @pow_f64(double %x, double %y) #0 {
@@ -1038,6 +1052,7 @@ declare float @llvm.experimental.constrained.powi.f32(float, i32, metadata, meta
10381052
declare float @llvm.experimental.constrained.sin.f32(float, metadata, metadata)
10391053
declare float @llvm.experimental.constrained.cos.f32(float, metadata, metadata)
10401054
declare float @llvm.experimental.constrained.tan.f32(float, metadata, metadata)
1055+
declare float @llvm.experimental.constrained.atan2.f32(float, float, metadata, metadata)
10411056
declare float @llvm.experimental.constrained.pow.f32(float, float, metadata, metadata)
10421057
declare float @llvm.experimental.constrained.log.f32(float, metadata, metadata)
10431058
declare float @llvm.experimental.constrained.log10.f32(float, metadata, metadata)
@@ -1072,6 +1087,7 @@ declare double @llvm.experimental.constrained.powi.f64(double, i32, metadata, me
10721087
declare double @llvm.experimental.constrained.sin.f64(double, metadata, metadata)
10731088
declare double @llvm.experimental.constrained.cos.f64(double, metadata, metadata)
10741089
declare double @llvm.experimental.constrained.tan.f64(double, metadata, metadata)
1090+
declare double @llvm.experimental.constrained.atan2.f64(double, double, metadata, metadata)
10751091
declare double @llvm.experimental.constrained.pow.f64(double, double, metadata, metadata)
10761092
declare double @llvm.experimental.constrained.log.f64(double, metadata, metadata)
10771093
declare double @llvm.experimental.constrained.log10.f64(double, metadata, metadata)

llvm/test/CodeGen/PowerPC/ctrloop-constrained-fp.ll

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,63 @@ for.body:
132132
br i1 %cond, label %exit, label %for.body
133133
}
134134

135+
; Check constrained ops converted to call
136+
define void @testAtan2(ptr %cast1, ptr %cast2) strictfp {
137+
; CHECK-LABEL: testAtan2:
138+
; CHECK: # %bb.0: # %root
139+
; CHECK-NEXT: mflr 0
140+
; CHECK-NEXT: .cfi_def_cfa_offset 64
141+
; CHECK-NEXT: .cfi_offset lr, 16
142+
; CHECK-NEXT: .cfi_offset r28, -32
143+
; CHECK-NEXT: .cfi_offset r29, -24
144+
; CHECK-NEXT: .cfi_offset r30, -16
145+
; CHECK-NEXT: std 28, -32(1) # 8-byte Folded Spill
146+
; CHECK-NEXT: std 29, -24(1) # 8-byte Folded Spill
147+
; CHECK-NEXT: std 30, -16(1) # 8-byte Folded Spill
148+
; CHECK-NEXT: stdu 1, -64(1)
149+
; CHECK-NEXT: addi 30, 3, -8
150+
; CHECK-NEXT: addi 29, 4, -8
151+
; CHECK-NEXT: li 28, 255
152+
; CHECK-NEXT: std 0, 80(1)
153+
; CHECK-NEXT: .p2align 5
154+
; CHECK-NEXT: .LBB3_1: # %for.body
155+
; CHECK-NEXT: #
156+
; CHECK-NEXT: lfdu 2, 8(29)
157+
; CHECK-NEXT: lfdu 1, 8(30)
158+
; CHECK-NEXT: bl atan2
159+
; CHECK-NEXT: nop
160+
; CHECK-NEXT: addi 28, 28, -1
161+
; CHECK-NEXT: stfd 1, 0(30)
162+
; CHECK-NEXT: cmpldi 28, 0
163+
; CHECK-NEXT: bc 12, 1, .LBB3_1
164+
; CHECK-NEXT: # %bb.2: # %exit
165+
; CHECK-NEXT: addi 1, 1, 64
166+
; CHECK-NEXT: ld 0, 16(1)
167+
; CHECK-NEXT: ld 30, -16(1) # 8-byte Folded Reload
168+
; CHECK-NEXT: ld 29, -24(1) # 8-byte Folded Reload
169+
; CHECK-NEXT: ld 28, -32(1) # 8-byte Folded Reload
170+
; CHECK-NEXT: mtlr 0
171+
; CHECK-NEXT: blr
172+
root:
173+
br label %for.body
174+
175+
exit:
176+
ret void
177+
178+
for.body:
179+
%i = phi i64 [ 0, %root ], [ %next, %for.body ]
180+
%idx1 = getelementptr inbounds double, ptr %cast1, i64 %i
181+
%idx2 = getelementptr inbounds double, ptr %cast2, i64 %i
182+
%val1 = load double, ptr %idx1
183+
%val2 = load double, ptr %idx2
184+
%tan = tail call nnan ninf nsz arcp double @llvm.experimental.constrained.atan2.f64(double %val1, double %val2, metadata !"round.dynamic", metadata !"fpexcept.strict")
185+
store double %tan, ptr %idx1, align 8
186+
%next = add nuw nsw i64 %i, 1
187+
%cond = icmp eq i64 %next, 255
188+
br i1 %cond, label %exit, label %for.body
189+
}
190+
135191
declare double @llvm.experimental.constrained.cos.f64(double, metadata, metadata)
136192
declare double @llvm.experimental.constrained.tan.f64(double, metadata, metadata)
193+
declare double @llvm.experimental.constrained.atan2.f64(double, double, metadata, metadata)
137194
declare double @llvm.experimental.constrained.sqrt.f64(double, metadata, metadata)

llvm/test/CodeGen/RISCV/double-intrinsics-strict.ll

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1635,3 +1635,63 @@ define i64 @llround_f64(double %a) nounwind strictfp {
16351635
%1 = call i64 @llvm.experimental.constrained.llround.i64.f64(double %a, metadata !"fpexcept.strict") strictfp
16361636
ret i64 %1
16371637
}
1638+
1639+
declare double @llvm.experimental.constrained.atan2.f64(double, double, metadata, metadata)
1640+
1641+
define double @atan2_f64(double %a, double %b) nounwind strictfp {
1642+
; RV32IFD-LABEL: atan2_f64:
1643+
; RV32IFD: # %bb.0:
1644+
; RV32IFD-NEXT: addi sp, sp, -16
1645+
; RV32IFD-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
1646+
; RV32IFD-NEXT: call atan2
1647+
; RV32IFD-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
1648+
; RV32IFD-NEXT: addi sp, sp, 16
1649+
; RV32IFD-NEXT: ret
1650+
;
1651+
; RV64IFD-LABEL: atan2_f64:
1652+
; RV64IFD: # %bb.0:
1653+
; RV64IFD-NEXT: addi sp, sp, -16
1654+
; RV64IFD-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
1655+
; RV64IFD-NEXT: call atan2
1656+
; RV64IFD-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
1657+
; RV64IFD-NEXT: addi sp, sp, 16
1658+
; RV64IFD-NEXT: ret
1659+
;
1660+
; RV32IZFINXZDINX-LABEL: atan2_f64:
1661+
; RV32IZFINXZDINX: # %bb.0:
1662+
; RV32IZFINXZDINX-NEXT: addi sp, sp, -16
1663+
; RV32IZFINXZDINX-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
1664+
; RV32IZFINXZDINX-NEXT: call atan2
1665+
; RV32IZFINXZDINX-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
1666+
; RV32IZFINXZDINX-NEXT: addi sp, sp, 16
1667+
; RV32IZFINXZDINX-NEXT: ret
1668+
;
1669+
; RV64IZFINXZDINX-LABEL: atan2_f64:
1670+
; RV64IZFINXZDINX: # %bb.0:
1671+
; RV64IZFINXZDINX-NEXT: addi sp, sp, -16
1672+
; RV64IZFINXZDINX-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
1673+
; RV64IZFINXZDINX-NEXT: call atan2
1674+
; RV64IZFINXZDINX-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
1675+
; RV64IZFINXZDINX-NEXT: addi sp, sp, 16
1676+
; RV64IZFINXZDINX-NEXT: ret
1677+
;
1678+
; RV32I-LABEL: atan2_f64:
1679+
; RV32I: # %bb.0:
1680+
; RV32I-NEXT: addi sp, sp, -16
1681+
; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
1682+
; RV32I-NEXT: call atan2
1683+
; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
1684+
; RV32I-NEXT: addi sp, sp, 16
1685+
; RV32I-NEXT: ret
1686+
;
1687+
; RV64I-LABEL: atan2_f64:
1688+
; RV64I: # %bb.0:
1689+
; RV64I-NEXT: addi sp, sp, -16
1690+
; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
1691+
; RV64I-NEXT: call atan2
1692+
; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
1693+
; RV64I-NEXT: addi sp, sp, 16
1694+
; RV64I-NEXT: ret
1695+
%1 = call double @llvm.experimental.constrained.atan2.f64(double %a, double %b, metadata !"round.dynamic", metadata !"fpexcept.strict") strictfp
1696+
ret double %1
1697+
}

0 commit comments

Comments
 (0)