[llvm] 63901cb - [Scalarizer] Scalarize freeze instruction
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 9 05:54:36 PDT 2023
Author: Jay Foad
Date: 2023-06-09T13:54:24+01:00
New Revision: 63901cb082add8d471a834df420a11a510664d4c
URL: https://github.com/llvm/llvm-project/commit/63901cb082add8d471a834df420a11a510664d4c
DIFF: https://github.com/llvm/llvm-project/commit/63901cb082add8d471a834df420a11a510664d4c.diff
LOG: [Scalarizer] Scalarize freeze instruction
Differential Revision: https://reviews.llvm.org/D152518
Added:
Modified:
llvm/lib/Transforms/Scalar/Scalarizer.cpp
llvm/test/Transforms/Scalarizer/basic.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/Scalarizer.cpp b/llvm/lib/Transforms/Scalar/Scalarizer.cpp
index 954da7c33edc9..f321bea17d7d6 100644
--- a/llvm/lib/Transforms/Scalar/Scalarizer.cpp
+++ b/llvm/lib/Transforms/Scalar/Scalarizer.cpp
@@ -228,6 +228,7 @@ class ScalarizerVisitor : public InstVisitor<ScalarizerVisitor, bool> {
bool visitLoadInst(LoadInst &LI);
bool visitStoreInst(StoreInst &SI);
bool visitCallInst(CallInst &ICI);
+ bool visitFreezeInst(FreezeInst &FI);
private:
Scatterer scatter(Instruction *Point, Value *V, Type *PtrElemTy = nullptr);
@@ -972,6 +973,12 @@ bool ScalarizerVisitor::visitCallInst(CallInst &CI) {
return splitCall(CI);
}
+bool ScalarizerVisitor::visitFreezeInst(FreezeInst &FI) {
+ return splitUnary(FI, [](IRBuilder<> &Builder, Value *Op, const Twine &Name) {
+ return Builder.CreateFreeze(Op, Name);
+ });
+}
+
// Delete the instructions that we scalarized. If a full vector result
// is still needed, recreate it using InsertElements.
bool ScalarizerVisitor::finish() {
diff --git a/llvm/test/Transforms/Scalarizer/basic.ll b/llvm/test/Transforms/Scalarizer/basic.ll
index c5824ce621458..ddc942f6488d7 100644
--- a/llvm/test/Transforms/Scalarizer/basic.ll
+++ b/llvm/test/Transforms/Scalarizer/basic.ll
@@ -833,7 +833,12 @@ define <2 x i32> @f23_crash(<2 x i32> %srcvec, i32 %v1) {
define <2 x i32> @f24(<2 x i32> %src) {
; CHECK-LABEL: @f24(
-; CHECK-NEXT: [[FRZ:%.*]] = freeze <2 x i32> [[SRC:%.*]]
+; CHECK-NEXT: [[SRC_I0:%.*]] = extractelement <2 x i32> [[SRC:%.*]], i64 0
+; CHECK-NEXT: [[FRZ_I0:%.*]] = freeze i32 [[SRC_I0]]
+; CHECK-NEXT: [[SRC_I1:%.*]] = extractelement <2 x i32> [[SRC]], i64 1
+; CHECK-NEXT: [[FRZ_I1:%.*]] = freeze i32 [[SRC_I1]]
+; CHECK-NEXT: [[FRZ_UPTO0:%.*]] = insertelement <2 x i32> poison, i32 [[FRZ_I0]], i64 0
+; CHECK-NEXT: [[FRZ:%.*]] = insertelement <2 x i32> [[FRZ_UPTO0]], i32 [[FRZ_I1]], i64 1
; CHECK-NEXT: ret <2 x i32> [[FRZ]]
;
%frz = freeze <2 x i32> %src
@@ -846,12 +851,9 @@ define <2 x float> @f25(<2 x float> %src) {
; CHECK-NEXT: [[ADD_I0:%.*]] = fadd float [[SRC_I0]], [[SRC_I0]]
; CHECK-NEXT: [[SRC_I1:%.*]] = extractelement <2 x float> [[SRC]], i64 1
; CHECK-NEXT: [[ADD_I1:%.*]] = fadd float [[SRC_I1]], [[SRC_I1]]
-; CHECK-NEXT: [[ADD_UPTO0:%.*]] = insertelement <2 x float> poison, float [[ADD_I0]], i64 0
-; CHECK-NEXT: [[ADD:%.*]] = insertelement <2 x float> [[ADD_UPTO0]], float [[ADD_I1]], i64 1
-; CHECK-NEXT: [[FRZ:%.*]] = freeze <2 x float> [[ADD]]
-; CHECK-NEXT: [[FRZ_I0:%.*]] = extractelement <2 x float> [[FRZ]], i64 0
+; CHECK-NEXT: [[FRZ_I0:%.*]] = freeze float [[ADD_I0]]
+; CHECK-NEXT: [[FRZ_I1:%.*]] = freeze float [[ADD_I1]]
; CHECK-NEXT: [[MUL_I0:%.*]] = fmul float [[FRZ_I0]], [[FRZ_I0]]
-; CHECK-NEXT: [[FRZ_I1:%.*]] = extractelement <2 x float> [[FRZ]], i64 1
; CHECK-NEXT: [[MUL_I1:%.*]] = fmul float [[FRZ_I1]], [[FRZ_I1]]
; CHECK-NEXT: [[MUL_UPTO0:%.*]] = insertelement <2 x float> poison, float [[MUL_I0]], i64 0
; CHECK-NEXT: [[MUL:%.*]] = insertelement <2 x float> [[MUL_UPTO0]], float [[MUL_I1]], i64 1
More information about the llvm-commits
mailing list