[PATCH] D138454: GlobalISel: Enable CSE of G_SELECT
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 21 12:55:06 PST 2022
arsenm created this revision.
arsenm added reviewers: aemerson, paquette, Pierre-vh.
Herald added subscribers: kosarev, kerbowa, hiraditya, jvesely.
Herald added a project: All.
arsenm requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.
Stop trying to delete a select in one combine since it would
be deleting the CSE'd instruction if that happened.
https://reviews.llvm.org/D138454
Files:
llvm/lib/CodeGen/GlobalISel/CSEInfo.cpp
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
llvm/test/CodeGen/AMDGPU/GlobalISel/combine-fold-binop-into-select.mir
Index: llvm/test/CodeGen/AMDGPU/GlobalISel/combine-fold-binop-into-select.mir
===================================================================
--- llvm/test/CodeGen/AMDGPU/GlobalISel/combine-fold-binop-into-select.mir
+++ llvm/test/CodeGen/AMDGPU/GlobalISel/combine-fold-binop-into-select.mir
@@ -938,8 +938,8 @@
; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
; CHECK-NEXT: %ten:_(s32) = G_CONSTANT i32 10
; CHECK-NEXT: %twenty:_(s32) = G_CONSTANT i32 20
- ; CHECK-NEXT: %smin:_(s32) = G_SELECT %cond(s1), %ten, %twenty
- ; CHECK-NEXT: S_ENDPGM 0, implicit %smin(s32)
+ ; CHECK-NEXT: %select:_(s32) = G_SELECT %cond(s1), %ten, %twenty
+ ; CHECK-NEXT: S_ENDPGM 0, implicit %select(s32)
%reg:_(s32) = COPY $vgpr0
%zero:_(s32) = G_CONSTANT i32 0
%cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
@@ -987,8 +987,8 @@
; CHECK-NEXT: %cond:_(s1) = G_ICMP intpred(eq), %reg(s32), %zero
; CHECK-NEXT: %ten:_(s32) = G_CONSTANT i32 10
; CHECK-NEXT: %twenty:_(s32) = G_CONSTANT i32 20
- ; CHECK-NEXT: %umin:_(s32) = G_SELECT %cond(s1), %ten, %twenty
- ; CHECK-NEXT: S_ENDPGM 0, implicit %umin(s32)
+ ; CHECK-NEXT: %select:_(s32) = G_SELECT %cond(s1), %ten, %twenty
+ ; CHECK-NEXT: S_ENDPGM 0, implicit %select(s32)
%reg:_(s32) = COPY $vgpr0
%zero:_(s32) = G_CONSTANT i32 0
%cond:_(s1) = G_ICMP intpred(eq), %reg, %zero
Index: llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
===================================================================
--- llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
+++ llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
@@ -3196,8 +3196,6 @@
}
Builder.buildSelect(Dst, SelectCond, FoldTrue, FoldFalse, MI.getFlags());
- Observer.erasingInstr(*Select);
- Select->eraseFromParent();
MI.eraseFromParent();
return true;
Index: llvm/lib/CodeGen/GlobalISel/CSEInfo.cpp
===================================================================
--- llvm/lib/CodeGen/GlobalISel/CSEInfo.cpp
+++ llvm/lib/CodeGen/GlobalISel/CSEInfo.cpp
@@ -61,6 +61,7 @@
case TargetOpcode::G_TRUNC:
case TargetOpcode::G_PTR_ADD:
case TargetOpcode::G_EXTRACT:
+ case TargetOpcode::G_SELECT:
return true;
}
return false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138454.476978.patch
Type: text/x-patch
Size: 2236 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221121/bcba696f/attachment.bin>
More information about the llvm-commits
mailing list