diff options
author | Yusuke MINATO <minato.yusuke@fujitsu.com> | 2024-10-28 23:19:20 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-28 14:19:20 +0000 |
commit | bd6ab32e6eb642f2b0b15be8c7c2a668192f07d8 (patch) | |
tree | 1f830778f4efbe89588856bd0988cf1c1d15f2e5 /flang/lib | |
parent | 42eb54b7743df421af10ebe14b67bb79b46ecabb (diff) | |
download | llvm-bd6ab32e6eb642f2b0b15be8c7c2a668192f07d8.zip llvm-bd6ab32e6eb642f2b0b15be8c7c2a668192f07d8.tar.gz llvm-bd6ab32e6eb642f2b0b15be8c7c2a668192f07d8.tar.bz2 |
Revert "[flang] Integrate the option -flang-experimental-integer-overflow into -fno-wrapv" (#113901)
Reverts llvm/llvm-project#110063 due to the performance regression on
503.bwaves_r in SPEC2017.
Diffstat (limited to 'flang/lib')
-rw-r--r-- | flang/lib/Frontend/CompilerInvocation.cpp | 6 | ||||
-rw-r--r-- | flang/lib/Frontend/FrontendActions.cpp | 4 | ||||
-rw-r--r-- | flang/lib/Lower/Bridge.cpp | 2 | ||||
-rw-r--r-- | flang/lib/Lower/IO.cpp | 2 | ||||
-rw-r--r-- | flang/lib/Optimizer/Passes/Pipelines.cpp | 6 | ||||
-rw-r--r-- | flang/lib/Optimizer/Transforms/ControlFlowConverter.cpp | 8 |
6 files changed, 17 insertions, 11 deletions
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp b/flang/lib/Frontend/CompilerInvocation.cpp index 5da5236..94d3d11 100644 --- a/flang/lib/Frontend/CompilerInvocation.cpp +++ b/flang/lib/Frontend/CompilerInvocation.cpp @@ -1350,6 +1350,12 @@ bool CompilerInvocation::createFromArgs( invoc.loweringOpts.setNoPPCNativeVecElemOrder(true); } + // -flang-experimental-integer-overflow + if (args.hasArg( + clang::driver::options::OPT_flang_experimental_integer_overflow)) { + invoc.loweringOpts.setNSWOnLoopVarInc(true); + } + // Preserve all the remark options requested, i.e. -Rpass, -Rpass-missed or // -Rpass-analysis. This will be used later when processing and outputting the // remarks generated by LLVM in ExecuteCompilerInvocation.cpp. diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp index 3ea2423..f2e460f 100644 --- a/flang/lib/Frontend/FrontendActions.cpp +++ b/flang/lib/Frontend/FrontendActions.cpp @@ -828,8 +828,8 @@ void CodeGenAction::generateLLVMIR() { config.VScaleMax = vsr->second; } - if (ci.getInvocation().getLoweringOpts().getIntegerWrapAround()) - config.NSWOnLoopVarInc = false; + if (ci.getInvocation().getLoweringOpts().getNSWOnLoopVarInc()) + config.NSWOnLoopVarInc = true; // Create the pass pipeline fir::createMLIRToLLVMPassPipeline(pm, config, getCurrentFile()); diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp index a3bd1ac..877fe122 100644 --- a/flang/lib/Lower/Bridge.cpp +++ b/flang/lib/Lower/Bridge.cpp @@ -2271,7 +2271,7 @@ private: assert(!incrementLoopNestInfo.empty() && "empty loop nest"); mlir::Location loc = toLocation(); mlir::arith::IntegerOverflowFlags flags{}; - if (!getLoweringOptions().getIntegerWrapAround()) + if (getLoweringOptions().getNSWOnLoopVarInc()) flags = bitEnumSet(flags, mlir::arith::IntegerOverflowFlags::nsw); auto iofAttr = mlir::arith::IntegerOverflowFlagsAttr::get( builder->getContext(), flags); diff --git a/flang/lib/Lower/IO.cpp b/flang/lib/Lower/IO.cpp index b534c81..1894b0c 100644 --- a/flang/lib/Lower/IO.cpp +++ b/flang/lib/Lower/IO.cpp @@ -929,7 +929,7 @@ static void genIoLoop(Fortran::lower::AbstractConverter &converter, fir::FirOpBuilder &builder = converter.getFirOpBuilder(); mlir::Location loc = converter.getCurrentLocation(); mlir::arith::IntegerOverflowFlags flags{}; - if (!converter.getLoweringOptions().getIntegerWrapAround()) + if (converter.getLoweringOptions().getNSWOnLoopVarInc()) flags = bitEnumSet(flags, mlir::arith::IntegerOverflowFlags::nsw); auto iofAttr = mlir::arith::IntegerOverflowFlagsAttr::get(builder.getContext(), flags); diff --git a/flang/lib/Optimizer/Passes/Pipelines.cpp b/flang/lib/Optimizer/Passes/Pipelines.cpp index 091b7c4..3c139f7 100644 --- a/flang/lib/Optimizer/Passes/Pipelines.cpp +++ b/flang/lib/Optimizer/Passes/Pipelines.cpp @@ -35,11 +35,11 @@ void addCanonicalizerPassWithoutRegionSimplification(mlir::OpPassManager &pm) { void addCfgConversionPass(mlir::PassManager &pm, const MLIRToLLVMPassPipelineConfig &config) { if (config.NSWOnLoopVarInc) + addNestedPassToAllTopLevelOperationsConditionally( + pm, disableCfgConversion, fir::createCFGConversionPassWithNSW); + else addNestedPassToAllTopLevelOperationsConditionally(pm, disableCfgConversion, fir::createCFGConversion); - else - addNestedPassToAllTopLevelOperationsConditionally( - pm, disableCfgConversion, fir::createCFGConversionPassWithoutNSW); } void addAVC(mlir::PassManager &pm, const llvm::OptimizationLevel &optLevel) { diff --git a/flang/lib/Optimizer/Transforms/ControlFlowConverter.cpp b/flang/lib/Optimizer/Transforms/ControlFlowConverter.cpp index 411bf7f..3b79d6d 100644 --- a/flang/lib/Optimizer/Transforms/ControlFlowConverter.cpp +++ b/flang/lib/Optimizer/Transforms/ControlFlowConverter.cpp @@ -332,6 +332,8 @@ class CfgConversion : public fir::impl::CFGConversionBase<CfgConversion> { public: using CFGConversionBase<CfgConversion>::CFGConversionBase; + CfgConversion(bool setNSW) { this->setNSW = setNSW; } + void runOnOperation() override { auto *context = &this->getContext(); mlir::RewritePatternSet patterns(context); @@ -364,8 +366,6 @@ void fir::populateCfgConversionRewrites(mlir::RewritePatternSet &patterns, patterns.getContext(), forceLoopToExecuteOnce, setNSW); } -std::unique_ptr<mlir::Pass> fir::createCFGConversionPassWithoutNSW() { - fir::CFGConversionOptions options; - options.setNSW = false; - return fir::createCFGConversion(options); +std::unique_ptr<mlir::Pass> fir::createCFGConversionPassWithNSW() { + return std::make_unique<CfgConversion>(true); } |