Skip to content

Commit 406b4ea

Browse files
pkarvetigithub-actions[bot]
authored andcommitted
Automerge: [Hexagon] Added lowering for sint_to_fp from v32i1 to v32f32 (#159507)
The transformation pattern is identical to the uint_to_fp conversion from v32i1 to v32f32.
2 parents 4d25c1f + df65494 commit 406b4ea

File tree

3 files changed

+45
-27
lines changed

3 files changed

+45
-27
lines changed

llvm/lib/Target/Hexagon/HexagonISelLoweringHVX.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,7 @@ HexagonTargetLowering::initializeHVXLowering() {
449449
// Include cases which are not hander earlier
450450
setOperationAction(ISD::UINT_TO_FP, MVT::v32i1, Custom);
451451
setOperationAction(ISD::UINT_TO_FP, MVT::v64i1, Custom);
452+
setOperationAction(ISD::SINT_TO_FP, MVT::v32i1, Custom);
452453

453454
setTargetDAGCombine({ISD::CONCAT_VECTORS, ISD::TRUNCATE, ISD::VSELECT});
454455
}
@@ -2337,7 +2338,7 @@ HexagonTargetLowering::LowerHvxFpToInt(SDValue Op, SelectionDAG &DAG) const {
23372338
return ExpandHvxFpToInt(Op, DAG);
23382339
}
23392340

2340-
// For vector type v32i1 uint_to_fp to v32f32:
2341+
// For vector type v32i1 uint_to_fp/sint_to_fp to v32f32:
23412342
// R1 = #1, R2 holds the v32i1 param
23422343
// V1 = vsplat(R1)
23432344
// V2 = vsplat(R2)
@@ -2464,7 +2465,7 @@ HexagonTargetLowering::LowerHvxIntToFp(SDValue Op, SelectionDAG &DAG) const {
24642465
MVT IntTy = ty(Op.getOperand(0)).getVectorElementType();
24652466
MVT FpTy = ResTy.getVectorElementType();
24662467

2467-
if (Op.getOpcode() == ISD::UINT_TO_FP) {
2468+
if (Op.getOpcode() == ISD::UINT_TO_FP || Op.getOpcode() == ISD::SINT_TO_FP) {
24682469
if (ResTy == MVT::v32f32 && ty(Op.getOperand(0)) == MVT::v32i1)
24692470
return LowerHvxPred32ToFp(Op, DAG);
24702471
if (ResTy == MVT::v64f16 && ty(Op.getOperand(0)) == MVT::v64i1)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
; Tests lowering of v32i1 to v32f32
2+
3+
; RUN: llc -march=hexagon -mattr=+hvxv79,+hvx-length128b,+hvx-ieee-fp \
4+
; RUN: -stop-after=hexagon-isel %s -o - | FileCheck %s
5+
6+
define <32 x float> @uitofp_i1(<32 x i16> %in0, <32 x i16> %in1) #0 {
7+
; CHECK: name: uitofp_i1
8+
; CHECK: [[R0:%[0-9]+]]:hvxvr = V6_lvsplatw killed %{{[0-9]+}}
9+
; CHECK-NEXT: [[R1:%[0-9]+]]:intregs = A2_tfrsi 1
10+
; CHECK-NEXT: [[R2:%[0-9]+]]:hvxvr = V6_lvsplatw [[R1]]
11+
; CHECK-NEXT: [[R3:%[0-9]+]]:hvxqr = V6_vandvrt [[R2]], [[R1]]
12+
; CHECK-NEXT: [[R4:%[0-9]+]]:hvxvr = V6_vprefixqw killed [[R3]]
13+
; CHECK-NEXT: [[R5:%[0-9]+]]:hvxvr = V6_vsubw killed [[R4]], [[R2]]
14+
; CHECK-NEXT: [[R6:%[0-9]+]]:hvxvr = V6_vlsrwv killed [[R0]], killed [[R5]]
15+
; CHECK-NEXT: [[R7:%[0-9]+]]:hvxvr = V6_vand killed [[R6]], [[R2]]
16+
; CHECK-NEXT: [[R8:%[0-9]+]]:hvxvr = V6_vconv_sf_w killed [[R7]]
17+
; CHECK-NEXT: hvxvr = V6_vadd_sf_sf [[R8]], [[R8]]
18+
%q1 = icmp eq <32 x i16> %in0, %in1
19+
%fp0 = uitofp <32 x i1> %q1 to <32 x float>
20+
%out = fadd <32 x float> %fp0, %fp0
21+
ret <32 x float> %out
22+
}
23+
24+
define <32 x float> @sitofp_i1(<32 x i16> %in0, <32 x i16> %in1) #0 {
25+
; CHECK: name: sitofp_i1
26+
; CHECK: [[R0:%[0-9]+]]:hvxvr = V6_lvsplatw killed %{{[0-9]+}}
27+
; CHECK-NEXT: [[R1:%[0-9]+]]:intregs = A2_tfrsi 1
28+
; CHECK-NEXT: [[R2:%[0-9]+]]:hvxvr = V6_lvsplatw [[R1]]
29+
; CHECK-NEXT: [[R3:%[0-9]+]]:hvxqr = V6_vandvrt [[R2]], [[R1]]
30+
; CHECK-NEXT: [[R4:%[0-9]+]]:hvxvr = V6_vprefixqw killed [[R3]]
31+
; CHECK-NEXT: [[R5:%[0-9]+]]:hvxvr = V6_vsubw killed [[R4]], [[R2]]
32+
; CHECK-NEXT: [[R6:%[0-9]+]]:hvxvr = V6_vlsrwv killed [[R0]], killed [[R5]]
33+
; CHECK-NEXT: [[R7:%[0-9]+]]:hvxvr = V6_vand killed [[R6]], [[R2]]
34+
; CHECK-NEXT: [[R8:%[0-9]+]]:hvxvr = V6_vconv_sf_w killed [[R7]]
35+
; CHECK-NEXT: hvxvr = V6_vadd_sf_sf [[R8]], [[R8]]
36+
%q1 = icmp eq <32 x i16> %in0, %in1
37+
%fp0 = sitofp <32 x i1> %q1 to <32 x float>
38+
%out = fadd <32 x float> %fp0, %fp0
39+
ret <32 x float> %out
40+
}
41+
42+
attributes #0 = { nounwind readnone "target-cpu"="hexagonv79" "target-features"="+hvxv79,+hvx-length128b" }

llvm/test/CodeGen/Hexagon/isel-uinttofp-v32i1tov32f32.ll

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)