Skip to content
This repository was archived by the owner on Sep 2, 2018. It is now read-only.

Commit 73235dc

Browse files
committed
Do not assume that FP vector operands are never legalized by expanding
This patch ensures that if a floating point vector operand is legalized by expanding, it is legalized through the stack rather than by calling DAGTypeLegalizer::IntegerToVector which will cause a failure since the operand is a non-integer type. This fixes PR 30715. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285231 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent cf6e9a8 commit 73235dc

File tree

2 files changed

+76
-1
lines changed

2 files changed

+76
-1
lines changed

lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,8 @@ void DAGTypeLegalizer::IntegerToVector(SDValue Op, unsigned NumElements,
336336

337337
SDValue DAGTypeLegalizer::ExpandOp_BITCAST(SDNode *N) {
338338
SDLoc dl(N);
339-
if (N->getValueType(0).isVector()) {
339+
if (N->getValueType(0).isVector() &&
340+
N->getOperand(0).getValueType().isInteger()) {
340341
// An illegal expanding type is being converted to a legal vector type.
341342
// Make a two element vector out of the expanded parts and convert that
342343
// instead, but only if the new vector type is legal (otherwise there

test/CodeGen/PowerPC/pr30715.ll

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
; RUN: llc -verify-machineinstrs -mcpu=pwr8 -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s
2+
3+
%class.FullMatrix = type { i8 }
4+
%class.Vector = type { float* }
5+
6+
$test = comdat any
7+
8+
define weak_odr void @test(%class.FullMatrix* %this, %class.Vector* dereferenceable(8) %p1, %class.Vector* dereferenceable(8), i1 zeroext) {
9+
entry:
10+
%call = tail call signext i32 @fn1(%class.FullMatrix* %this)
11+
%cmp10 = icmp sgt i32 %call, 0
12+
br i1 %cmp10, label %for.body.lr.ph, label %for.cond.cleanup
13+
14+
for.body.lr.ph: ; preds = %entry
15+
%val.i = getelementptr inbounds %class.Vector, %class.Vector* %p1, i64 0, i32 0
16+
%2 = load float*, float** %val.i, align 8
17+
%wide.trip.count = zext i32 %call to i64
18+
%min.iters.check = icmp ult i32 %call, 4
19+
br i1 %min.iters.check, label %for.body.preheader, label %min.iters.checked
20+
21+
for.body.preheader: ; preds = %middle.block, %min.iters.checked, %for.body.lr.ph
22+
%indvars.iv.ph = phi i64 [ 0, %min.iters.checked ], [ 0, %for.body.lr.ph ], [ %n.vec, %middle.block ]
23+
br label %for.body
24+
25+
min.iters.checked: ; preds = %for.body.lr.ph
26+
%3 = and i32 %call, 3
27+
%n.mod.vf = zext i32 %3 to i64
28+
%n.vec = sub nsw i64 %wide.trip.count, %n.mod.vf
29+
%cmp.zero = icmp eq i64 %n.vec, 0
30+
br i1 %cmp.zero, label %for.body.preheader, label %vector.body.preheader
31+
32+
vector.body.preheader: ; preds = %min.iters.checked
33+
br label %vector.body
34+
35+
vector.body: ; preds = %vector.body.preheader, %vector.body
36+
%index = phi i64 [ %index.next, %vector.body ], [ 0, %vector.body.preheader ]
37+
%4 = getelementptr inbounds float, float* %2, i64 %index
38+
%5 = bitcast float* %4 to <4 x float>*
39+
%wide.load = load <4 x float>, <4 x float>* %5, align 4
40+
%6 = fpext <4 x float> %wide.load to <4 x ppc_fp128>
41+
%7 = fadd <4 x ppc_fp128> %6, undef
42+
%8 = fptrunc <4 x ppc_fp128> %7 to <4 x float>
43+
%9 = bitcast float* %4 to <4 x float>*
44+
store <4 x float> %8, <4 x float>* %9, align 4
45+
%index.next = add i64 %index, 4
46+
%10 = icmp eq i64 %index.next, %n.vec
47+
br i1 %10, label %middle.block, label %vector.body
48+
49+
middle.block: ; preds = %vector.body
50+
%cmp.n = icmp eq i32 %3, 0
51+
br i1 %cmp.n, label %for.cond.cleanup, label %for.body.preheader
52+
53+
for.cond.cleanup.loopexit: ; preds = %for.body
54+
br label %for.cond.cleanup
55+
56+
for.cond.cleanup: ; preds = %for.cond.cleanup.loopexit, %middle.block, %entry
57+
ret void
58+
59+
for.body: ; preds = %for.body.preheader, %for.body
60+
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ %indvars.iv.ph, %for.body.preheader ]
61+
%arrayidx.i = getelementptr inbounds float, float* %2, i64 %indvars.iv
62+
%11 = load float, float* %arrayidx.i, align 4
63+
%conv = fpext float %11 to ppc_fp128
64+
%add = fadd ppc_fp128 %conv, undef
65+
%conv4 = fptrunc ppc_fp128 %add to float
66+
store float %conv4, float* %arrayidx.i, align 4
67+
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
68+
%exitcond = icmp eq i64 %indvars.iv.next, %wide.trip.count
69+
br i1 %exitcond, label %for.cond.cleanup.loopexit, label %for.body
70+
; CHECK: stxsdx
71+
; CHECK: lxvd2x
72+
}
73+
74+
declare signext i32 @fn1(%class.FullMatrix*) local_unnamed_addr #1

0 commit comments

Comments
 (0)