[llvm] b521716 - [GVN] Execute performLoopLoadPRE ahead of PerformLoadPRE
Jingu Kang via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 24 01:51:45 PDT 2021
Author: Jingu Kang
Date: 2021-08-24T09:50:27+01:00
New Revision: b52171629f567fdd120987db95ffc977207c960a
URL: https://github.com/llvm/llvm-project/commit/b52171629f567fdd120987db95ffc977207c960a
DIFF: https://github.com/llvm/llvm-project/commit/b52171629f567fdd120987db95ffc977207c960a.diff
LOG: [GVN] Execute performLoopLoadPRE ahead of PerformLoadPRE
Differential Revision: https://reviews.llvm.org/D108204
Added:
Modified:
llvm/lib/Transforms/Scalar/GVN.cpp
llvm/test/Transforms/GVN/gvn-loop-load-pre-order.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp
index 79750aec2c5db..f43279a1131a3 100644
--- a/llvm/lib/Transforms/Scalar/GVN.cpp
+++ b/llvm/lib/Transforms/Scalar/GVN.cpp
@@ -1673,8 +1673,8 @@ bool GVN::processNonLocalLoad(LoadInst *Load) {
if (!isLoadInLoopPREEnabled() && LI && LI->getLoopFor(Load->getParent()))
return Changed;
- if (PerformLoadPRE(Load, ValuesPerBlock, UnavailableBlocks) ||
- performLoopLoadPRE(Load, ValuesPerBlock, UnavailableBlocks))
+ if (performLoopLoadPRE(Load, ValuesPerBlock, UnavailableBlocks) ||
+ PerformLoadPRE(Load, ValuesPerBlock, UnavailableBlocks))
return true;
return Changed;
diff --git a/llvm/test/Transforms/GVN/gvn-loop-load-pre-order.ll b/llvm/test/Transforms/GVN/gvn-loop-load-pre-order.ll
index 8da767cc0db10..972e6037a7046 100644
--- a/llvm/test/Transforms/GVN/gvn-loop-load-pre-order.ll
+++ b/llvm/test/Transforms/GVN/gvn-loop-load-pre-order.ll
@@ -12,17 +12,16 @@ define void @main(i1 %cond) {
; CHECK-PRE: while.cond.loopexit.loopexit:
; CHECK-PRE-NEXT: ret void
; CHECK-PRE: while.body3:
-; CHECK-PRE-NEXT: [[TMP0:%.*]] = phi i32 [ [[DOTPRE:%.*]], [[IF_END_WHILE_BODY3_CRIT_EDGE:%.*]] ], [ 0, [[ENTRY:%.*]] ]
+; CHECK-PRE-NEXT: [[TMP0:%.*]] = phi i32 [ [[TMP1:%.*]], [[IF_END:%.*]] ], [ 0, [[ENTRY:%.*]] ]
; CHECK-PRE-NEXT: [[TOBOOL4_NOT:%.*]] = icmp eq i32 [[TMP0]], 0
-; CHECK-PRE-NEXT: br i1 [[TOBOOL4_NOT]], label [[IF_END:%.*]], label [[IF_THEN:%.*]]
+; CHECK-PRE-NEXT: br i1 [[TOBOOL4_NOT]], label [[IF_END]], label [[IF_THEN:%.*]]
; CHECK-PRE: if.then:
; CHECK-PRE-NEXT: tail call void @foo()
+; CHECK-PRE-NEXT: [[DOTPRE:%.*]] = load i32, i32* @b, align 4
; CHECK-PRE-NEXT: br label [[IF_END]]
; CHECK-PRE: if.end:
-; CHECK-PRE-NEXT: br i1 [[COND:%.*]], label [[WHILE_COND_LOOPEXIT_LOOPEXIT:%.*]], label [[IF_END_WHILE_BODY3_CRIT_EDGE]]
-; CHECK-PRE: if.end.while.body3_crit_edge:
-; CHECK-PRE-NEXT: [[DOTPRE]] = load i32, i32* @b, align 4
-; CHECK-PRE-NEXT: br label [[WHILE_BODY3]]
+; CHECK-PRE-NEXT: [[TMP1]] = phi i32 [ [[DOTPRE]], [[IF_THEN]] ], [ 0, [[WHILE_BODY3]] ]
+; CHECK-PRE-NEXT: br i1 [[COND:%.*]], label [[WHILE_COND_LOOPEXIT_LOOPEXIT:%.*]], label [[WHILE_BODY3]]
;
; CHECK-SCCP-LABEL: @main(
; CHECK-SCCP-NEXT: entry:
@@ -31,17 +30,11 @@ define void @main(i1 %cond) {
; CHECK-SCCP: while.cond.loopexit.loopexit:
; CHECK-SCCP-NEXT: ret void
; CHECK-SCCP: while.body3:
-; CHECK-SCCP-NEXT: [[TMP0:%.*]] = phi i32 [ [[DOTPRE:%.*]], [[IF_END_WHILE_BODY3_CRIT_EDGE:%.*]] ], [ 0, [[ENTRY:%.*]] ]
-; CHECK-SCCP-NEXT: [[TOBOOL4_NOT:%.*]] = icmp eq i32 [[TMP0]], 0
-; CHECK-SCCP-NEXT: br i1 [[TOBOOL4_NOT]], label [[IF_END:%.*]], label [[IF_THEN:%.*]]
+; CHECK-SCCP-NEXT: br i1 true, label [[IF_END:%.*]], label [[IF_THEN:%.*]]
; CHECK-SCCP: if.then:
-; CHECK-SCCP-NEXT: tail call void @foo()
; CHECK-SCCP-NEXT: br label [[IF_END]]
; CHECK-SCCP: if.end:
-; CHECK-SCCP-NEXT: br i1 [[COND:%.*]], label [[WHILE_COND_LOOPEXIT_LOOPEXIT:%.*]], label [[IF_END_WHILE_BODY3_CRIT_EDGE]]
-; CHECK-SCCP: if.end.while.body3_crit_edge:
-; CHECK-SCCP-NEXT: [[DOTPRE]] = load i32, i32* @b, align 4
-; CHECK-SCCP-NEXT: br label [[WHILE_BODY3]]
+; CHECK-SCCP-NEXT: br i1 [[COND:%.*]], label [[WHILE_COND_LOOPEXIT_LOOPEXIT:%.*]], label [[WHILE_BODY3]]
;
entry:
store i32 0, i32* @b
More information about the llvm-commits
mailing list