Skip to content

Commit cbd7eab

Browse files
committed
Revert "[ConstantFold] Handle vectors in ConstantFoldLoadThroughBitcast()"
That commit caused chromium build to crash: https://bugs.chromium.org/p/chromium/issues/detail?id=1188885 This reverts commit edf7004.
1 parent 5f58aae commit cbd7eab

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

llvm/lib/Analysis/ConstantFolding.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,11 @@ Constant *llvm::ConstantFoldLoadThroughBitcast(Constant *C, Type *DestTy,
387387
return ConstantExpr::getCast(Cast, C, DestTy);
388388
}
389389

390+
// If this isn't an aggregate type, there is nothing we can do to drill down
391+
// and find a bitcastable constant.
392+
if (!SrcTy->isAggregateType())
393+
return nullptr;
394+
390395
// We're simulating a load through a pointer that was bitcast to point to
391396
// a different type, so we can try to walk down through the initial
392397
// elements of an aggregate to see if some part of the aggregate is

llvm/test/Transforms/GVN/non-integral-pointers-inseltpoison.ll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,14 @@ entry:
213213
ret i64 addrspace(4)* %ref
214214
}
215215

216+
; TODO: missed optimization
216217
define i8 addrspace(4)* @forward_memcopy(i8 addrspace(4)* addrspace(4)* %loc) {
217218
; CHECK-LABEL: @forward_memcopy(
218219
; CHECK-NEXT: entry:
219220
; CHECK-NEXT: [[LOC_BC:%.*]] = bitcast i8 addrspace(4)* addrspace(4)* [[LOC:%.*]] to i8 addrspace(4)*
220221
; CHECK-NEXT: call void @llvm.memcpy.p4i8.p0i8.i64(i8 addrspace(4)* align 4 [[LOC_BC]], i8* bitcast (<4 x i64 addrspace(4)*>* @NonZeroConstant2 to i8*), i64 8, i1 false)
221-
; CHECK-NEXT: ret i8 addrspace(4)* bitcast (i64 addrspace(4)* getelementptr (i64, i64 addrspace(4)* null, i32 3) to i8 addrspace(4)*)
222+
; CHECK-NEXT: [[REF:%.*]] = load i8 addrspace(4)*, i8 addrspace(4)* addrspace(4)* [[LOC]], align 8
223+
; CHECK-NEXT: ret i8 addrspace(4)* [[REF]]
222224
;
223225
entry:
224226
%loc.bc = bitcast i8 addrspace(4)* addrspace(4)* %loc to i8 addrspace(4)*

llvm/test/Transforms/GVN/non-integral-pointers.ll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,14 @@ entry:
213213
ret i64 addrspace(4)* %ref
214214
}
215215

216+
; TODO: missed optimization
216217
define i8 addrspace(4)* @forward_memcopy(i8 addrspace(4)* addrspace(4)* %loc) {
217218
; CHECK-LABEL: @forward_memcopy(
218219
; CHECK-NEXT: entry:
219220
; CHECK-NEXT: [[LOC_BC:%.*]] = bitcast i8 addrspace(4)* addrspace(4)* [[LOC:%.*]] to i8 addrspace(4)*
220221
; CHECK-NEXT: call void @llvm.memcpy.p4i8.p0i8.i64(i8 addrspace(4)* align 4 [[LOC_BC]], i8* bitcast (<4 x i64 addrspace(4)*>* @NonZeroConstant2 to i8*), i64 8, i1 false)
221-
; CHECK-NEXT: ret i8 addrspace(4)* bitcast (i64 addrspace(4)* getelementptr (i64, i64 addrspace(4)* null, i32 3) to i8 addrspace(4)*)
222+
; CHECK-NEXT: [[REF:%.*]] = load i8 addrspace(4)*, i8 addrspace(4)* addrspace(4)* [[LOC]], align 8
223+
; CHECK-NEXT: ret i8 addrspace(4)* [[REF]]
222224
;
223225
entry:
224226
%loc.bc = bitcast i8 addrspace(4)* addrspace(4)* %loc to i8 addrspace(4)*

0 commit comments

Comments
 (0)