Skip to content

Commit 91131b6

Browse files
committed
[SelectionDAG] soften assertion when legalizing narrow vector FP ops
The test based on PR42010: https://bugs.llvm.org/show_bug.cgi?id=42010 ...may show an inaccuracy for PPC's target defs, but we should not be so aggressive with an assert here. There's no telling what out-of-tree targets look like. llvm-svn: 361696
1 parent bb76cf0 commit 91131b6

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2743,13 +2743,11 @@ void DAGTypeLegalizer::WidenVectorResult(SDNode *N, unsigned ResNo) {
27432743
// We're going to widen this vector op to a legal type by padding with undef
27442744
// elements. If the wide vector op is eventually going to be expanded to
27452745
// scalar libcalls, then unroll into scalar ops now to avoid unnecessary
2746-
// libcalls on the undef elements. We are assuming that if the scalar op
2747-
// requires expanding, then the vector op needs expanding too.
2746+
// libcalls on the undef elements.
27482747
EVT VT = N->getValueType(0);
2749-
if (TLI.isOperationExpand(N->getOpcode(), VT.getScalarType())) {
2750-
EVT WideVecVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
2751-
assert(!TLI.isOperationLegalOrCustom(N->getOpcode(), WideVecVT) &&
2752-
"Target supports vector op, but scalar requires expansion?");
2748+
EVT WideVecVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
2749+
if (!TLI.isOperationLegalOrCustom(N->getOpcode(), WideVecVT) &&
2750+
TLI.isOperationExpand(N->getOpcode(), VT.getScalarType())) {
27532751
Res = DAG.UnrollVectorOp(N, WideVecVT.getVectorNumElements());
27542752
break;
27552753
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+
; RUN: llc -mtriple=powerpc64-- -mattr=altivec -verify-machineinstrs < %s | FileCheck %s
3+
4+
; This would assert because the widened vector op is
5+
; legal/custom, but the scalar op is expanded.
6+
7+
define i32 @PR42010(<2 x float> %x) {
8+
; CHECK-LABEL: PR42010:
9+
; CHECK: # %bb.0:
10+
; CHECK-NEXT: addi 3, 1, -32
11+
; CHECK-NEXT: vrfiz 2, 2
12+
; CHECK-NEXT: stvx 2, 0, 3
13+
; CHECK-NEXT: lfs 0, -28(1)
14+
; CHECK-NEXT: fctiwz 0, 0
15+
; CHECK-NEXT: stfd 0, -8(1)
16+
; CHECK-NEXT: lwz 3, -4(1)
17+
; CHECK-NEXT: blr
18+
%t0 = call <2 x float> @llvm.trunc.v2f32(<2 x float> %x)
19+
%t1 = extractelement <2 x float> %t0, i32 1
20+
%t2 = fptosi float %t1 to i32
21+
ret i32 %t2
22+
}
23+
24+
declare <2 x float> @llvm.trunc.v2f32(<2 x float>)

0 commit comments

Comments
 (0)