Skip to content

Commit 0eeff74

Browse files
committed
Revert "Don't look through addrspacecast in GetPointerBaseWithConstantOffset"
This reverts commit 4478320. Reason: Breaks Analysis/ValueTracking/get-pointer-base-with-const-off.ll
1 parent 7180520 commit 0eeff74

File tree

4 files changed

+15
-42
lines changed

4 files changed

+15
-42
lines changed

lib/Analysis/ValueTracking.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2854,14 +2854,9 @@ Value *llvm::GetPointerBaseWithConstantOffset(Value *Ptr, int64_t &Offset,
28542854
ByteOffset += GEPOffset.getSExtValue();
28552855

28562856
Ptr = GEP->getPointerOperand();
2857-
} else if (Operator::getOpcode(Ptr) == Instruction::BitCast) {
2857+
} else if (Operator::getOpcode(Ptr) == Instruction::BitCast ||
2858+
Operator::getOpcode(Ptr) == Instruction::AddrSpaceCast) {
28582859
Ptr = cast<Operator>(Ptr)->getOperand(0);
2859-
} else if (AddrSpaceCastInst *ASCI = dyn_cast<AddrSpaceCastInst>(Ptr)) {
2860-
Value *SourcePtr = ASCI->getPointerOperand();
2861-
// Don't look through addrspace cast which changes pointer size
2862-
if (BitWidth != DL.getPointerTypeSizeInBits(SourcePtr->getType()))
2863-
break;
2864-
Ptr = SourcePtr;
28652860
} else if (GlobalAlias *GA = dyn_cast<GlobalAlias>(Ptr)) {
28662861
if (GA->isInterposable())
28672862
break;

test/Transforms/GVN/PRE/rle-addrspace-cast.ll

Lines changed: 0 additions & 14 deletions
This file was deleted.

test/Transforms/GVN/PRE/rle.ll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,19 @@ define i8 @coerce_offset0(i32 %V, i32* %P) {
318318
; CHECK: ret i8
319319
}
320320

321+
define i8 @coerce_offset0_addrspacecast(i32 %V, i32* %P) {
322+
store i32 %V, i32* %P
323+
324+
%P2 = addrspacecast i32* %P to i8 addrspace(1)*
325+
%P3 = getelementptr i8, i8 addrspace(1)* %P2, i32 2
326+
327+
%A = load i8, i8 addrspace(1)* %P3
328+
ret i8 %A
329+
; CHECK-LABEL: @coerce_offset0_addrspacecast(
330+
; CHECK-NOT: load
331+
; CHECK: ret i8
332+
}
333+
321334
;; non-local i32/float -> i8 load forwarding.
322335
define i8 @coerce_offset_nonlocal0(i32* %P, i1 %cond) {
323336
%P2 = bitcast i32* %P to float*

test/Transforms/GVN/addrspace-cast.ll

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)