Conversation
Backfills a set of passes and reorderings from Julia's `pipeline.cpp` that were missing from `buildNewPMPipeline!`: - Early simplification: add InferFunctionAttrs, move DCE before SimplifyCFG, add EarlyCSE after SROA, and the GlobalOpt + Promote + InstCombine tail at O>=1. - Early optimizer: gate the CGSCC AllocOpt/Float2Int/LowerConstantIntrinsics adaptor on O>=2, reorder the function-level sequence, add AggressiveInstCombine + ConstraintElimination, switch EarlyCSE to MSSA, and close with GlobalOpt + GlobalDCE. - Loop optimizer: merge into a single MSSA-enabled LPM with LoopInstSimplify + LoopSimplifyCFG + pre-rotate LICM (no speculation) + LoopRotate + LICM + SimpleLoopUnswitch, then run SimplifyCFG + InstCombine between the two loop sub-pipelines. - Scalar optimizer: add MergedLoadStoreMotion, BDCE, ADCE, ConstraintElimination and an early VectorCombine at O>=2; add an O>=1 path mirroring Julia's lighter sequence; replace the LoopDeletion/LoopInstSimplify + LoopDistribute tail with an LICM/JuliaLICM LPM followed by SimplifyCFG + InstCombine. - Vector pipeline: prepend a LoopRotate + LoopDeletion LPM, run LoopDistribute here instead of in scalar opts, and add the post-vectorize LICM + EarlyCSE + CVP + InstCombine cleanup plus the SROA(PreserveCFG) + InstSimplify tail.
- Add LibCallsShrinkWrapPass in the early-optimizer O>=2 function sequence (between CorrelatedValuePropagation and Reassociate), matching Julia. A no-op on modules without libc-shaped calls, but beneficial on libdevice-using PTX code. - Gate the cleanup-pipeline GVN tail on opt_level >= 2 to match Julia (was opt_level >= 1).
Set the `nvvm-reflect-ftz` module flag from `target.fastmath` in `finish_module!` — the same channel Clang uses for `-fcuda-flush-denormals-to-zero`, and the only `__nvvm_reflect` key that LLVM's upstream NVVMReflectPass honors besides `__CUDA_ARCH`. On LLVM 17+, that pass now runs via the PipelineStart EP callback we wire up in `buildEarlySimplificationPipeline`. Simplify the custom `nvvm_reflect!` fallback (LLVM < 17) to match upstream semantics: `__CUDA_ARCH` from the target capability, `__CUDA_FTZ` from the module flag, every other key folds to 0. The previous fastmath-derived handling of `__CUDA_PREC_DIV` / `__CUDA_PREC_SQRT` / `__CUDA_FMAD` is dropped; callers that want those behaviors should rely on LLVM fast-math flags on the FP ops themselves.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uses JuliaLLVM/LLVM.jl#524 to improve our pipeline, adding the callbacks needed to e.g. avoid manual NVVMReflect. Also changes the NVVMReflect semantics to match LLVM's, which will need some adaptation in CUDA.jl (though nothing crucial warranting a breaking release). Finally, also align the pipeline with Julia's one more closely.