[llvm-branch-commits] [llvm-branch] r317857 - Cherry-pick r317444 to google/testing.
David L. Jones via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Nov 9 17:15:52 PST 2017
Author: dlj
Date: Thu Nov 9 17:15:52 2017
New Revision: 317857
URL: http://llvm.org/viewvc/llvm-project?rev=317857&view=rev
Log:
Cherry-pick r317444 to google/testing.
Modified:
llvm/branches/google/testing/ (props changed)
llvm/branches/google/testing/include/llvm/Transforms/Scalar/SimplifyCFG.h
llvm/branches/google/testing/lib/Passes/PassBuilder.cpp
llvm/branches/google/testing/test/Transforms/PhaseOrdering/simplifycfg-options.ll
Propchange: llvm/branches/google/testing/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Nov 9 17:15:52 2017
@@ -1,3 +1,3 @@
/llvm/branches/Apple/Pertwee:110850,110961
/llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241
+/llvm/trunk:155241,317444
Modified: llvm/branches/google/testing/include/llvm/Transforms/Scalar/SimplifyCFG.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/google/testing/include/llvm/Transforms/Scalar/SimplifyCFG.h?rev=317857&r1=317856&r2=317857&view=diff
==============================================================================
--- llvm/branches/google/testing/include/llvm/Transforms/Scalar/SimplifyCFG.h (original)
+++ llvm/branches/google/testing/include/llvm/Transforms/Scalar/SimplifyCFG.h Thu Nov 9 17:15:52 2017
@@ -31,16 +31,16 @@ class SimplifyCFGPass : public PassInfoM
SimplifyCFGOptions Options;
public:
- /// The default constructor sets the pass options to create canonical IR,
- /// rather than optimal IR. That is, by default we bypass transformations that
- /// are likely to improve performance but make analysis for other passes more
- /// difficult.
+ /// The default constructor sets the pass options to create optimal IR,
+ /// rather than canonical IR. That is, by default we do transformations that
+ /// are likely to improve performance but make analysis more difficult.
+ /// FIXME: This is inverted from what most instantiations of the pass should
+ /// be.
SimplifyCFGPass()
: SimplifyCFGPass(SimplifyCFGOptions()
- .forwardSwitchCondToPhi(false)
- .convertSwitchToLookupTable(false)
- .needCanonicalLoops(true)) {}
-
+ .forwardSwitchCondToPhi(true)
+ .convertSwitchToLookupTable(true)
+ .needCanonicalLoops(false)) {}
/// Construct a pass with optional optimizations.
SimplifyCFGPass(const SimplifyCFGOptions &PassOptions);
Modified: llvm/branches/google/testing/lib/Passes/PassBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/google/testing/lib/Passes/PassBuilder.cpp?rev=317857&r1=317856&r2=317857&view=diff
==============================================================================
--- llvm/branches/google/testing/lib/Passes/PassBuilder.cpp (original)
+++ llvm/branches/google/testing/lib/Passes/PassBuilder.cpp Thu Nov 9 17:15:52 2017
@@ -751,13 +751,8 @@ PassBuilder::buildModuleOptimizationPipe
// Optimize parallel scalar instruction chains into SIMD instructions.
OptimizePM.addPass(SLPVectorizerPass());
- // Cleanup after all of the vectorizers. Simplification passes like CVP and
- // GVN, loop transforms, and others have already run, so it's now better to
- // convert to more optimized IR using more aggressive simplify CFG options.
- OptimizePM.addPass(SimplifyCFGPass(SimplifyCFGOptions().
- forwardSwitchCondToPhi(true).
- convertSwitchToLookupTable(true).
- needCanonicalLoops(false)));
+ // Cleanup after all of the vectorizers.
+ OptimizePM.addPass(SimplifyCFGPass());
OptimizePM.addPass(InstCombinePass());
// Unroll small loops to hide loop backedge latency and saturate any parallel
Modified: llvm/branches/google/testing/test/Transforms/PhaseOrdering/simplifycfg-options.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/google/testing/test/Transforms/PhaseOrdering/simplifycfg-options.ll?rev=317857&r1=317856&r2=317857&view=diff
==============================================================================
--- llvm/branches/google/testing/test/Transforms/PhaseOrdering/simplifycfg-options.ll (original)
+++ llvm/branches/google/testing/test/Transforms/PhaseOrdering/simplifycfg-options.ll Thu Nov 9 17:15:52 2017
@@ -1,36 +1,63 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt -O1 -S < %s | FileCheck %s --check-prefix=ALL --check-prefix=OLDPM
-; RUN: opt -passes='default<O1>' -S < %s | FileCheck %s --check-prefix=ALL --check-prefix=NEWPM
-
-declare void @foo()
+; RUN: opt -O1 -S < %s | FileCheck %s --check-prefix=OLDPM
+; RUN: opt -passes='default<O1>' -S < %s | FileCheck %s --check-prefix=NEWPM
; Don't simplify unconditional branches from empty blocks in simplifyCFG
; until late in the pipeline because it can destroy canonical loop structure.
+; FIXME: The new pass manager is not limiting simplifycfg at any point in the pipeline,
+; so it performs a transformation before loop optimizations that is avoided in the old PM.
+
define i1 @PR33605(i32 %a, i32 %b, i32* %c) {
-; ALL-LABEL: @PR33605(
-; ALL-NEXT: for.body:
-; ALL-NEXT: [[OR:%.*]] = or i32 [[B:%.*]], [[A:%.*]]
-; ALL-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[C:%.*]], i64 1
-; ALL-NEXT: [[TMP0:%.*]] = load i32, i32* [[ARRAYIDX]], align 4
-; ALL-NEXT: [[CMP:%.*]] = icmp eq i32 [[OR]], [[TMP0]]
-; ALL-NEXT: br i1 [[CMP]], label [[IF_END:%.*]], label [[IF_THEN:%.*]]
-; ALL: if.then:
-; ALL-NEXT: store i32 [[OR]], i32* [[ARRAYIDX]], align 4
-; ALL-NEXT: tail call void @foo()
-; ALL-NEXT: br label [[IF_END]]
-; ALL: if.end:
-; ALL-NEXT: [[CHANGED_1_OFF0:%.*]] = phi i1 [ true, [[IF_THEN]] ], [ false, [[FOR_BODY:%.*]] ]
-; ALL-NEXT: [[TMP1:%.*]] = load i32, i32* [[C]], align 4
-; ALL-NEXT: [[CMP_1:%.*]] = icmp eq i32 [[OR]], [[TMP1]]
-; ALL-NEXT: br i1 [[CMP_1]], label [[IF_END_1:%.*]], label [[IF_THEN_1:%.*]]
-; ALL: if.then.1:
-; ALL-NEXT: store i32 [[OR]], i32* [[C]], align 4
-; ALL-NEXT: tail call void @foo()
-; ALL-NEXT: br label [[IF_END_1]]
-; ALL: if.end.1:
-; ALL-NEXT: [[CHANGED_1_OFF0_1:%.*]] = phi i1 [ true, [[IF_THEN_1]] ], [ [[CHANGED_1_OFF0]], [[IF_END]] ]
-; ALL-NEXT: ret i1 [[CHANGED_1_OFF0_1]]
+; OLDPM-LABEL: @PR33605(
+; OLDPM-NEXT: for.body:
+; OLDPM-NEXT: [[OR:%.*]] = or i32 [[B:%.*]], [[A:%.*]]
+; OLDPM-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[C:%.*]], i64 1
+; OLDPM-NEXT: [[TMP0:%.*]] = load i32, i32* [[ARRAYIDX]], align 4
+; OLDPM-NEXT: [[CMP:%.*]] = icmp eq i32 [[OR]], [[TMP0]]
+; OLDPM-NEXT: br i1 [[CMP]], label [[IF_END:%.*]], label [[IF_THEN:%.*]]
+; OLDPM: if.then:
+; OLDPM-NEXT: store i32 [[OR]], i32* [[ARRAYIDX]], align 4
+; OLDPM-NEXT: tail call void @foo()
+; OLDPM-NEXT: br label [[IF_END]]
+; OLDPM: if.end:
+; OLDPM-NEXT: [[CHANGED_1_OFF0:%.*]] = phi i1 [ true, [[IF_THEN]] ], [ false, [[FOR_BODY:%.*]] ]
+; OLDPM-NEXT: [[TMP1:%.*]] = load i32, i32* [[C]], align 4
+; OLDPM-NEXT: [[CMP_1:%.*]] = icmp eq i32 [[OR]], [[TMP1]]
+; OLDPM-NEXT: br i1 [[CMP_1]], label [[IF_END_1:%.*]], label [[IF_THEN_1:%.*]]
+; OLDPM: if.then.1:
+; OLDPM-NEXT: store i32 [[OR]], i32* [[C]], align 4
+; OLDPM-NEXT: tail call void @foo()
+; OLDPM-NEXT: br label [[IF_END_1]]
+; OLDPM: if.end.1:
+; OLDPM-NEXT: [[CHANGED_1_OFF0_1:%.*]] = phi i1 [ true, [[IF_THEN_1]] ], [ [[CHANGED_1_OFF0]], [[IF_END]] ]
+; OLDPM-NEXT: ret i1 [[CHANGED_1_OFF0_1]]
+;
+; NEWPM-LABEL: @PR33605(
+; NEWPM-NEXT: entry:
+; NEWPM-NEXT: [[OR:%.*]] = or i32 [[B:%.*]], [[A:%.*]]
+; NEWPM-NEXT: br label [[FOR_COND_OUTER:%.*]]
+; NEWPM: for.cond.outer:
+; NEWPM-NEXT: [[I_0_PH:%.*]] = phi i32 [ [[DEC:%.*]], [[IF_THEN:%.*]] ], [ 2, [[ENTRY:%.*]] ]
+; NEWPM-NEXT: [[CHANGED_0_OFF0_PH:%.*]] = phi i1 [ true, [[IF_THEN]] ], [ false, [[ENTRY]] ]
+; NEWPM-NEXT: br label [[FOR_COND:%.*]]
+; NEWPM: for.cond:
+; NEWPM-NEXT: [[I_0:%.*]] = phi i32 [ [[DEC]], [[FOR_BODY:%.*]] ], [ [[I_0_PH]], [[FOR_COND_OUTER]] ]
+; NEWPM-NEXT: [[DEC]] = add nsw i32 [[I_0]], -1
+; NEWPM-NEXT: [[TOBOOL:%.*]] = icmp eq i32 [[I_0]], 0
+; NEWPM-NEXT: br i1 [[TOBOOL]], label [[FOR_COND_CLEANUP:%.*]], label [[FOR_BODY]]
+; NEWPM: for.cond.cleanup:
+; NEWPM-NEXT: ret i1 [[CHANGED_0_OFF0_PH]]
+; NEWPM: for.body:
+; NEWPM-NEXT: [[IDXPROM:%.*]] = sext i32 [[DEC]] to i64
+; NEWPM-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, i32* [[C:%.*]], i64 [[IDXPROM]]
+; NEWPM-NEXT: [[TMP0:%.*]] = load i32, i32* [[ARRAYIDX]], align 4
+; NEWPM-NEXT: [[CMP:%.*]] = icmp eq i32 [[OR]], [[TMP0]]
+; NEWPM-NEXT: br i1 [[CMP]], label [[FOR_COND]], label [[IF_THEN]]
+; NEWPM: if.then:
+; NEWPM-NEXT: store i32 [[OR]], i32* [[ARRAYIDX]], align 4
+; NEWPM-NEXT: tail call void @foo()
+; NEWPM-NEXT: br label [[FOR_COND_OUTER]]
;
entry:
br label %for.cond
@@ -64,43 +91,5 @@ if.end:
br label %for.cond
}
-; PR34603 - https://bugs.llvm.org/show_bug.cgi?id=34603
-; We should have a select of doubles, not a select of double pointers.
-; SimplifyCFG should not flatten this before early-cse has a chance to eliminate redundant ops.
-
-define double @max_of_loads(double* %x, double* %y, i64 %i) {
-; ALL-LABEL: @max_of_loads(
-; ALL-NEXT: entry:
-; ALL-NEXT: [[XI_PTR:%.*]] = getelementptr double, double* [[X:%.*]], i64 [[I:%.*]]
-; ALL-NEXT: [[YI_PTR:%.*]] = getelementptr double, double* [[Y:%.*]], i64 [[I]]
-; ALL-NEXT: [[XI:%.*]] = load double, double* [[XI_PTR]], align 8
-; ALL-NEXT: [[YI:%.*]] = load double, double* [[YI_PTR]], align 8
-; ALL-NEXT: [[CMP:%.*]] = fcmp ogt double [[XI]], [[YI]]
-; ALL-NEXT: [[Y_SINK:%.*]] = select i1 [[CMP]], double* [[X]], double* [[Y]]
-; ALL-NEXT: [[YI_PTR_AGAIN:%.*]] = getelementptr double, double* [[Y_SINK]], i64 [[I]]
-; ALL-NEXT: [[YI_AGAIN:%.*]] = load double, double* [[YI_PTR_AGAIN]], align 8
-; ALL-NEXT: ret double [[YI_AGAIN]]
-;
-entry:
- %xi_ptr = getelementptr double, double* %x, i64 %i
- %yi_ptr = getelementptr double, double* %y, i64 %i
- %xi = load double, double* %xi_ptr
- %yi = load double, double* %yi_ptr
- %cmp = fcmp ogt double %xi, %yi
- br i1 %cmp, label %if, label %else
-
-if:
- %xi_ptr_again = getelementptr double, double* %x, i64 %i
- %xi_again = load double, double* %xi_ptr_again
- br label %end
-
-else:
- %yi_ptr_again = getelementptr double, double* %y, i64 %i
- %yi_again = load double, double* %yi_ptr_again
- br label %end
-
-end:
- %max = phi double [ %xi_again, %if ], [ %yi_again, %else ]
- ret double %max
-}
+declare void @foo()
More information about the llvm-branch-commits
mailing list