Files
swift-mirror/SwiftCompilerSources/Sources/Optimizer/InstructionSimplification/SimplifyMoveValue.swift
T
Erik Eckstein 2d2b457be4 Optimizer: simplify move_value
The `move_value` instruction is only used to specify flags.
Remove a `move_value` which either doesn't specify any flags or which flags are not relevant outside the mandatory pipeline, like `[lexical]`.
2026-03-10 07:56:49 +01:00

39 lines
1.1 KiB
Swift

//===--- SimplifyMoveValue.swift ------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
import SIL
/// The `move_value` instruction is only used to specify flags.
/// Remove a `move_value` which either doesn't specify any flags or which flags are not relevant
/// outside the mandatory pipeline, like `[lexical]`.
///
/// Replaces
///
/// ```
/// %1 = move_value %0
/// use %1
/// ```
/// ->
/// ```
/// use %0
/// ```
///
extension MoveValueInst : Simplifiable, SILCombineSimplifiable {
func simplify(_ context: SimplifyContext) {
if hasPointerEscape {
// Keep this flag.
return
}
replace(with: fromValue, context)
}
}