Skip to content

Commit ebfbdeb

Browse files
committed
[PowerPC] Fix store-fptoi combine of f128 on Power8
llc would crash for (store (fptosi-f128-i32)) when -mcpu=pwr8, we should not generate FP_TO_(S|U)INT_IN_VSR for f128 types at this time. This patch fixes it. Reviewed By: steven.zhang Differential Revision: https://reviews.llvm.org/D86686
1 parent 5782ab0 commit ebfbdeb

File tree

2 files changed

+77
-2
lines changed

2 files changed

+77
-2
lines changed

llvm/lib/Target/PowerPC/PPCISelLowering.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14094,8 +14094,7 @@ SDValue PPCTargetLowering::combineStoreFPToInt(SDNode *N,
1409414094
EVT Op1VT = N->getOperand(1).getValueType();
1409514095
EVT ResVT = Val.getValueType();
1409614096

14097-
// Floating point types smaller than 32 bits are not legal on Power.
14098-
if (ResVT.getScalarSizeInBits() < 32)
14097+
if (!isTypeLegal(ResVT))
1409914098
return SDValue();
1410014099

1410114100
// Only perform combine for conversion to i64/i32 or power9 i16/i8.

llvm/test/CodeGen/PowerPC/store_fptoi.ll

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,82 @@
77
; Tests for store of fp_to_sint converstions
88
; ==========================================
99

10+
; Function Attrs: norecurse nounwind
11+
define void @qpConv2sdw(fp128* nocapture readonly %a, i64* nocapture %b) {
12+
entry:
13+
%0 = load fp128, fp128* %a, align 16
14+
%conv = fptosi fp128 %0 to i64
15+
store i64 %conv, i64* %b, align 8
16+
ret void
17+
18+
; CHECK-LABEL: qpConv2sdw
19+
; CHECK: lxv [[LD:[0-9]+]], 0(3)
20+
; CHECK-NEXT: xscvqpsdz [[CONV:[0-9]+]], [[LD]]
21+
; CHECK-NEXT: stxsd [[CONV]], 0(4)
22+
; CHECK-NEXT: blr
23+
24+
; CHECK-PWR8-LABEL: qpConv2sdw
25+
; CHECK-PWR8: bl __fixkfdi
26+
; CHECK-PWR8: blr
27+
}
28+
29+
; Function Attrs: norecurse nounwind
30+
define void @qpConv2sw(fp128* nocapture readonly %a, i32* nocapture %b) {
31+
entry:
32+
%0 = load fp128, fp128* %a, align 16
33+
%conv = fptosi fp128 %0 to i32
34+
store i32 %conv, i32* %b, align 4
35+
ret void
36+
37+
; CHECK-LABEL: qpConv2sw
38+
; CHECK: lxv [[LD:[0-9]+]], 0(3)
39+
; CHECK-NEXT: xscvqpswz [[CONV:[0-9]+]], [[LD]]
40+
; CHECK-NEXT: stxsiwx [[CONV]], 0, 4
41+
; CHECK-NEXT: blr
42+
43+
; CHECK-PWR8-LABEL: qpConv2sw
44+
; CHECK-PWR8: bl __fixkfsi
45+
; CHECK-PWR8: blr
46+
}
47+
48+
; Function Attrs: norecurse nounwind
49+
define void @qpConv2udw(fp128* nocapture readonly %a, i64* nocapture %b) {
50+
entry:
51+
%0 = load fp128, fp128* %a, align 16
52+
%conv = fptoui fp128 %0 to i64
53+
store i64 %conv, i64* %b, align 8
54+
ret void
55+
56+
; CHECK-LABEL: qpConv2udw
57+
; CHECK: lxv [[LD:[0-9]+]], 0(3)
58+
; CHECK-NEXT: xscvqpudz [[CONV:[0-9]+]], [[LD]]
59+
; CHECK-NEXT: stxsd [[CONV]], 0(4)
60+
; CHECK-NEXT: blr
61+
62+
; CHECK-PWR8-LABEL: qpConv2udw
63+
; CHECK-PWR8: bl __fixunskfdi
64+
; CHECK-PWR8: blr
65+
}
66+
67+
; Function Attrs: norecurse nounwind
68+
define void @qpConv2uw(fp128* nocapture readonly %a, i32* nocapture %b) {
69+
entry:
70+
%0 = load fp128, fp128* %a, align 16
71+
%conv = fptoui fp128 %0 to i32
72+
store i32 %conv, i32* %b, align 4
73+
ret void
74+
75+
; CHECK-LABEL: qpConv2uw
76+
; CHECK: lxv [[LD:[0-9]+]], 0(3)
77+
; CHECK-NEXT: xscvqpuwz [[CONV:[0-9]+]], [[LD]]
78+
; CHECK-NEXT: stxsiwx [[CONV]], 0, 4
79+
; CHECK-NEXT: blr
80+
81+
; CHECK-PWR8-LABEL: qpConv2uw
82+
; CHECK-PWR8: bl __fixunskfsi
83+
; CHECK-PWR8: blr
84+
}
85+
1086
; Function Attrs: norecurse nounwind
1187
define void @dpConv2sdw(double* nocapture readonly %a, i64* nocapture %b) {
1288
entry:

0 commit comments

Comments
 (0)