Skip to content

InitializeStaticGlobals: handle InlineArray.init(repeating:) also for arm64_32 #81702

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ private extension StoreInst {
let headerBr = vectorBase.parentBlock.terminator as? BranchInst,
headerBr.targetBlock == parentBlock,
let vectorSize = vectorBase.vector.type.builtinFixedArraySizeType.valueOfInteger,
let (start, loopCount, increment) = getLoopInductionInfo(of: indexAddr.index.lookThroughTruncOrBitCast),
let (start, loopCount, increment) = getLoopInductionInfo(of: indexAddr.index.lookThroughIndexScalarCast),
start == 0, loopCount == vectorSize, increment == 1
{
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private func removeAddressToPointerToAddressPair(
///
private func simplifyIndexRawPointer(of ptr2Addr: PointerToAddressInst, _ context: SimplifyContext) -> Bool {
guard let indexRawPtr = ptr2Addr.pointer as? IndexRawPointerInst,
let tupleExtract = indexRawPtr.index.lookThroughTruncOrBitCast as? TupleExtractInst,
let tupleExtract = indexRawPtr.index.lookThroughIndexScalarCast as? TupleExtractInst,
let strideMul = tupleExtract.tuple as? BuiltinInst, strideMul.id == .SMulOver,
let (index, strideType) = strideMul.indexAndStrideOfMultiplication,
strideType == ptr2Addr.type.objectType
Expand Down Expand Up @@ -314,9 +314,9 @@ private extension BuiltinInst {

private extension Builder {
func createCastIfNeeded(of index: Value, toIndexTypeOf indexRawPtr: IndexRawPointerInst) -> Value {
if let truncOrBitCast = indexRawPtr.index as? BuiltinInst {
assert(truncOrBitCast.id == .TruncOrBitCast)
return createBuiltin(name: truncOrBitCast.name, type: truncOrBitCast.type, arguments: [index])
if let cast = indexRawPtr.index as? BuiltinInst {
assert(cast.id == .TruncOrBitCast || cast.id == .SExtOrBitCast)
return createBuiltin(name: cast.name, type: cast.type, arguments: [index])
}
return index
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,14 @@ extension Value {
}
}

var lookThroughTruncOrBitCast: Value {
if let truncOrBitCast = self as? BuiltinInst, truncOrBitCast.id == .TruncOrBitCast {
return truncOrBitCast.arguments[0]
var lookThroughIndexScalarCast: Value {
if let castBuiltin = self as? BuiltinInst {
switch castBuiltin.id {
case .TruncOrBitCast, .SExtOrBitCast:
return castBuiltin.arguments[0]
default:
return self
}
}
return self
}
Expand Down