Skip to content

Commit 383e350

Browse files
committed
[CaptureTracking] Treat vector GEPs as captures
Because AA does not support vectors of pointers, we have to treat pointers that are inserted into a vector as captures. We mostly already do so, but missed the case where getelementptr is used to produce a vector.
1 parent 292ecb8 commit 383e350

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

llvm/lib/Analysis/CaptureTracking.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,13 @@ UseCaptureKind llvm::DetermineUseCaptureKind(
361361
return UseCaptureKind::MAY_CAPTURE;
362362
return UseCaptureKind::NO_CAPTURE;
363363
}
364-
case Instruction::BitCast:
365364
case Instruction::GetElementPtr:
365+
// AA does not support pointers of vectors, so GEP vector splats need to
366+
// be considered as captures.
367+
if (I->getType()->isVectorTy())
368+
return UseCaptureKind::MAY_CAPTURE;
369+
return UseCaptureKind::PASSTHROUGH;
370+
case Instruction::BitCast:
366371
case Instruction::PHI:
367372
case Instruction::Select:
368373
case Instruction::AddrSpaceCast:

llvm/test/Transforms/GVN/captured-before.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,15 @@ loop:
133133
br label %loop
134134
}
135135

136-
; FIXME: This is a miscompile.
137136
define i32 @test_splat_gep_capture(<1 x i32> %index) {
138137
; CHECK-LABEL: define i32 @test_splat_gep_capture(
139138
; CHECK-SAME: <1 x i32> [[INDEX:%.*]]) {
140139
; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
141140
; CHECK-NEXT: store i32 123, ptr [[A]], align 4
142141
; CHECK-NEXT: [[PTRS:%.*]] = getelementptr inbounds i32, ptr [[A]], <1 x i32> [[INDEX]]
143142
; CHECK-NEXT: call void @some_call(<1 x ptr> [[PTRS]])
144-
; CHECK-NEXT: ret i32 123
143+
; CHECK-NEXT: [[RELOAD:%.*]] = load i32, ptr [[A]], align 4
144+
; CHECK-NEXT: ret i32 [[RELOAD]]
145145
;
146146
%a = alloca i32
147147
store i32 123, ptr %a

0 commit comments

Comments
 (0)