Skip to content

Commit d0f83d1

Browse files
committedSep 3, 2015
Fix IRBuilder CreateBitOrPointerCast for vector types
Summary: This function was not taking into account that the input type could be a vector, and wasn't properly working for vector types. This caused an assert when building spec2k6 perlbmk for armv8. Reviewers: rengolin, mzolotukhin Subscribers: silviu.baranga, mzolotukhin, rengolin, eugenis, jmolloy, aemerson, llvm-commits Differential Revision: http://reviews.llvm.org/D12559 llvm-svn: 246759
1 parent 3464dac commit d0f83d1

File tree

2 files changed

+73
-2
lines changed

2 files changed

+73
-2
lines changed
 

‎llvm/include/llvm/IR/IRBuilder.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -1364,9 +1364,11 @@ class IRBuilder : public IRBuilderBase, public Inserter {
13641364
const Twine &Name = "") {
13651365
if (V->getType() == DestTy)
13661366
return V;
1367-
if (V->getType()->isPointerTy() && DestTy->isIntegerTy())
1367+
if (V->getType()->getScalarType()->isPointerTy() &&
1368+
DestTy->getScalarType()->isIntegerTy())
13681369
return CreatePtrToInt(V, DestTy, Name);
1369-
if (V->getType()->isIntegerTy() && DestTy->isPointerTy())
1370+
if (V->getType()->getScalarType()->isIntegerTy() &&
1371+
DestTy->getScalarType()->isPointerTy())
13701372
return CreateIntToPtr(V, DestTy, Name);
13711373

13721374
return CreateBitCast(V, DestTy, Name);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
; RUN: opt -loop-vectorize -tbaa -S < %s | FileCheck %s
2+
3+
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
4+
target triple = "armv7--linux-gnueabi"
5+
6+
; This requires the loop vectorizer to create an interleaved access group
7+
; for the stores to the struct. Here we need to perform a bitcast from a vector
8+
; of pointers to a vector i32s.
9+
10+
%class.C = type { i8 }
11+
%class.B = type { %class.A* }
12+
%class.A = type { i8*, i32 }
13+
14+
; CHECK-LABEL: test0
15+
define void @test0(%class.C* nocapture readnone %this, %class.B* dereferenceable(4) %p1) #0 align 2 {
16+
entry:
17+
%call.i = tail call %class.A* @_ZN1B5m_fn2Ev(%class.B* nonnull %p1)
18+
%resize_I.i = getelementptr inbounds %class.B, %class.B* %p1, i32 0, i32 0
19+
%0 = load %class.A*, %class.A** %resize_I.i, align 4, !tbaa !3
20+
%cmp.6.i = icmp eq %class.A* %0, %call.i
21+
br i1 %cmp.6.i, label %_ZN1B5m_fn1Ev.exit, label %for.body.lr.ph.i
22+
23+
for.body.lr.ph.i: ; preds = %entry
24+
%resize_I.promoted8.i = ptrtoint %class.A* %0 to i32
25+
%scevgep.i = getelementptr %class.A, %class.A* %call.i, i32 -1, i32 0
26+
%1 = ptrtoint i8** %scevgep.i to i32
27+
%2 = sub i32 %1, %resize_I.promoted8.i
28+
br label %for.body.i
29+
30+
for.cond.for.cond.cleanup_crit_edge.i: ; preds = %for.body.i
31+
%3 = lshr i32 %2, 3
32+
%4 = add nuw nsw i32 %3, 1
33+
%scevgep10.i = getelementptr %class.A, %class.A* %0, i32 %4
34+
store %class.A* %scevgep10.i, %class.A** %resize_I.i, align 4, !tbaa !3
35+
br label %_ZN1B5m_fn1Ev.exit
36+
37+
for.body.i: ; preds = %for.body.i, %for.body.lr.ph.i
38+
%5 = phi %class.A* [ %0, %for.body.lr.ph.i ], [ %incdec.ptr.i, %for.body.i ]
39+
%Data.i.i = getelementptr inbounds %class.A, %class.A* %5, i32 0, i32 0
40+
store i8* null, i8** %Data.i.i, align 4, !tbaa !8
41+
%Length.i.i = getelementptr inbounds %class.A, %class.A* %5, i32 0, i32 1
42+
store i32 0, i32* %Length.i.i, align 4, !tbaa !11
43+
%incdec.ptr.i = getelementptr inbounds %class.A, %class.A* %5, i32 1
44+
%cmp.i = icmp eq %class.A* %incdec.ptr.i, %call.i
45+
br i1 %cmp.i, label %for.cond.for.cond.cleanup_crit_edge.i, label %for.body.i
46+
47+
_ZN1B5m_fn1Ev.exit: ; preds = %for.cond.for.cond.cleanup_crit_edge.i, %entry
48+
ret void
49+
}
50+
51+
declare %class.A* @_ZN1B5m_fn2Ev(%class.B*) #0
52+
53+
attributes #0 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="cortex-a8" "target-features"="+neon,+vfp3" "unsafe-fp-math"="false" "use-soft-float"="false" }
54+
55+
!llvm.module.flags = !{!0, !1}
56+
!llvm.ident = !{!2}
57+
58+
!0 = !{i32 1, !"wchar_size", i32 4}
59+
!1 = !{i32 1, !"min_enum_size", i32 4}
60+
!2 = !{!"clang version 3.8.0 (trunk 246510) (llvm/trunk 246509)"}
61+
!3 = !{!4, !5, i64 0}
62+
!4 = !{!"_ZTS1B", !5, i64 0}
63+
!5 = !{!"any pointer", !6, i64 0}
64+
!6 = !{!"omnipotent char", !7, i64 0}
65+
!7 = !{!"Simple C/C++ TBAA"}
66+
!8 = !{!9, !5, i64 0}
67+
!9 = !{!"_ZTS1A", !5, i64 0, !10, i64 4}
68+
!10 = !{!"int", !6, i64 0}
69+
!11 = !{!9, !10, i64 4}

0 commit comments

Comments
 (0)
Please sign in to comment.