Skip to content

Commit 05b4310

Browse files
committed
Revert "[Pipelines] Perform hoisting prior to GVN"
This reverts commit 1f37088 as it causes a large regression in x264, and some other regressions in downstream embedded benchmarks under LTO.
1 parent 8e7f032 commit 05b4310

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

llvm/lib/Passes/PassBuilderPipelines.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -640,9 +640,8 @@ PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level,
640640
FPM.addPass(createFunctionToLoopPassAdaptor(std::move(LPM1),
641641
/*UseMemorySSA=*/true,
642642
/*UseBlockFrequencyInfo=*/true));
643-
FPM.addPass(SimplifyCFGPass(
644-
SimplifyCFGOptions().hoistCommonInsts(true).convertSwitchRangeToICmp(
645-
true)));
643+
FPM.addPass(
644+
SimplifyCFGPass(SimplifyCFGOptions().convertSwitchRangeToICmp(true)));
646645
FPM.addPass(InstCombinePass());
647646
// The loop passes in LPM2 (LoopIdiomRecognizePass, IndVarSimplifyPass,
648647
// LoopDeletionPass and LoopFullUnrollPass) do not preserve MemorySSA.

llvm/test/Transforms/PhaseOrdering/gvn-replacement-vs-hoist.ll

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,26 @@ define void @test(ptr noundef %a, i32 noundef %beam) {
55
; CHECK-LABEL: define void @test
66
; CHECK-SAME: (ptr nocapture noundef writeonly [[A:%.*]], i32 noundef [[BEAM:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
77
; CHECK-NEXT: entry:
8+
; CHECK-NEXT: [[MUL:%.*]] = shl nuw nsw i32 [[BEAM]], 1
9+
; CHECK-NEXT: [[IDXPROM:%.*]] = zext i32 [[MUL]] to i64
10+
; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[IDXPROM]]
811
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
912
; CHECK: for.cond.cleanup:
1013
; CHECK-NEXT: ret void
1114
; CHECK: for.body:
12-
; CHECK-NEXT: [[I_06:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[INC:%.*]], [[FOR_BODY]] ]
13-
; CHECK-NEXT: [[CMP1:%.*]] = icmp ne i32 [[I_06]], [[BEAM]]
14-
; CHECK-NEXT: [[MUL:%.*]] = shl nuw nsw i32 [[I_06]], 1
15-
; CHECK-NEXT: [[IDXPROM:%.*]] = zext i32 [[MUL]] to i64
16-
; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[IDXPROM]]
17-
; CHECK-NEXT: [[SPEC_SELECT:%.*]] = zext i1 [[CMP1]] to i32
18-
; CHECK-NEXT: store i32 [[SPEC_SELECT]], ptr [[ARRAYIDX]], align 4
15+
; CHECK-NEXT: [[I_06:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[INC:%.*]], [[FOR_INC:%.*]] ]
16+
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[I_06]], [[BEAM]]
17+
; CHECK-NEXT: br i1 [[CMP1]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
18+
; CHECK: if.then:
19+
; CHECK-NEXT: store i32 0, ptr [[ARRAYIDX]], align 4
20+
; CHECK-NEXT: br label [[FOR_INC]]
21+
; CHECK: if.else:
22+
; CHECK-NEXT: [[MUL2:%.*]] = shl nuw nsw i32 [[I_06]], 1
23+
; CHECK-NEXT: [[IDXPROM3:%.*]] = zext i32 [[MUL2]] to i64
24+
; CHECK-NEXT: [[ARRAYIDX4:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[IDXPROM3]]
25+
; CHECK-NEXT: store i32 1, ptr [[ARRAYIDX4]], align 4
26+
; CHECK-NEXT: br label [[FOR_INC]]
27+
; CHECK: for.inc:
1928
; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_06]], 1
2029
; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[I_06]], 9999
2130
; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_COND_CLEANUP:%.*]]

llvm/test/Transforms/PhaseOrdering/loop-rotation-vs-common-code-hoisting.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ define void @_Z4loopi(i32 %width) {
5151
; HOIST-NEXT: br label [[FOR_COND:%.*]]
5252
; HOIST: for.cond:
5353
; HOIST-NEXT: [[I_0:%.*]] = phi i32 [ [[INC:%.*]], [[FOR_BODY:%.*]] ], [ 0, [[FOR_COND_PREHEADER]] ]
54-
; HOIST-NEXT: tail call void @f0()
5554
; HOIST-NEXT: [[EXITCOND_NOT:%.*]] = icmp eq i32 [[I_0]], [[SUB]]
55+
; HOIST-NEXT: tail call void @f0()
5656
; HOIST-NEXT: br i1 [[EXITCOND_NOT]], label [[FOR_COND_CLEANUP:%.*]], label [[FOR_BODY]]
5757
; HOIST: for.cond.cleanup:
5858
; HOIST-NEXT: tail call void @f2()

0 commit comments

Comments
 (0)