Skip to content

Commit 354d310

Browse files
author
Kai Luo
committed
[PowerPC] Skip combining (uint_to_fp x) if x is not simple type
Current powerpc64le backend hits ``` Combining: t7: f64 = uint_to_fp t6 llc: llvm-project/llvm/include/llvm/CodeGen/ValueTypes.h:291: llvm::MVT llvm::EVT::getSimpleVT() const: Assertion `isSimple() && "Expected a SimpleValueType!"' failed. ``` This patch fixes it by skipping combination if `t6` is not simple type. Fixed https://bugs.llvm.org/show_bug.cgi?id=47660. Reviewed By: #powerpc, steven.zhang Differential Revision: https://reviews.llvm.org/D88388
1 parent 2819631 commit 354d310

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

llvm/lib/Target/PowerPC/PPCISelLowering.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14075,6 +14075,8 @@ SDValue PPCTargetLowering::combineFPToIntToFP(SDNode *N,
1407514075
// from the hardware.
1407614076
if (Op.getValueType() != MVT::f32 && Op.getValueType() != MVT::f64)
1407714077
return SDValue();
14078+
if (!Op.getOperand(0).getValueType().isSimple())
14079+
return SDValue();
1407814080
if (Op.getOperand(0).getValueType().getSimpleVT() <= MVT(MVT::i1) ||
1407914081
Op.getOperand(0).getValueType().getSimpleVT() > MVT(MVT::i64))
1408014082
return SDValue();

llvm/test/CodeGen/PowerPC/pr47660.ll

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+
; RUN: llc -ppc-asm-full-reg-names -verify-machineinstrs \
3+
; RUN: -mtriple=powerpc64le-linux-gnu < %s | FileCheck \
4+
; RUN: -check-prefix=CHECK-LE %s
5+
; RUN: llc -ppc-asm-full-reg-names -verify-machineinstrs \
6+
; RUN: -mtriple=powerpc64-linux-gnu < %s | FileCheck \
7+
; RUN: -check-prefix=CHECK-BE %s
8+
9+
define dso_local i24 @_Z1f1c(i24 %g.coerce) local_unnamed_addr #0 {
10+
; CHECK-LE-LABEL: _Z1f1c:
11+
; CHECK-LE: # %bb.0: # %entry
12+
; CHECK-LE-NEXT: clrlwi r3, r3, 24
13+
; CHECK-LE-NEXT: xxlxor f1, f1, f1
14+
; CHECK-LE-NEXT: mtfprwz f0, r3
15+
; CHECK-LE-NEXT: xscvuxddp f0, f0
16+
; CHECK-LE-NEXT: xsmuldp f0, f0, f1
17+
; CHECK-LE-NEXT: xscvdpsxws f0, f0
18+
; CHECK-LE-NEXT: mffprwz r3, f0
19+
; CHECK-LE-NEXT: clrldi r3, r3, 32
20+
; CHECK-LE-NEXT: blr
21+
;
22+
; CHECK-BE-LABEL: _Z1f1c:
23+
; CHECK-BE: # %bb.0: # %entry
24+
; CHECK-BE-NEXT: clrldi r3, r3, 56
25+
; CHECK-BE-NEXT: std r3, -16(r1)
26+
; CHECK-BE-NEXT: addis r3, r2, .LCPI0_0@toc@ha
27+
; CHECK-BE-NEXT: lfd f0, -16(r1)
28+
; CHECK-BE-NEXT: lfs f1, .LCPI0_0@toc@l(r3)
29+
; CHECK-BE-NEXT: fcfid f0, f0
30+
; CHECK-BE-NEXT: fmul f0, f0, f1
31+
; CHECK-BE-NEXT: fctiwz f0, f0
32+
; CHECK-BE-NEXT: stfd f0, -8(r1)
33+
; CHECK-BE-NEXT: lwz r3, -4(r1)
34+
; CHECK-BE-NEXT: clrldi r3, r3, 32
35+
; CHECK-BE-NEXT: blr
36+
entry:
37+
%0 = and i24 %g.coerce, 255
38+
%conv1 = uitofp i24 %0 to double
39+
%mul = fmul double 0.000000e+00, %conv1
40+
%conv2 = fptoui double %mul to i8
41+
%retval.sroa.0.0.insert.ext = zext i8 %conv2 to i24
42+
ret i24 %retval.sroa.0.0.insert.ext
43+
}
44+
45+
attributes #0 = { "use-soft-float"="false" }

0 commit comments

Comments
 (0)