[llvm] [AMDGPU] PeepholeOptimizer - continue search next new source if a new source found is a subreg (PR #212563)

Yoonseo Choi via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 21 12:11:09 PDT 2026


================
@@ -1076,8 +1109,13 @@ bool PeepholeOptimizer::findNextSource(const TargetRegisterClass *DefRC,
       // constraints to the register allocator. Moreover, if we want to extend
       // the live-range of a physical register, unlike SSA virtual register,
       // we will have to check that they aren't redefine before the related use.
-      if (CurSrcPair.Reg.isPhysical())
+      if (CurSrcPair.Reg.isPhysical()) {
+        if (FoundSuitable) {
+          FallBackToSuitable();
----------------
yoonseoch wrote:

I don't have a more specific criteria of better candidates other than current PR's scalar over subreg sources at this point. Might be an extension to this PR if there is a good criteria? The fallback within the loop was in outdated code. Those were all hard-stopping "return false" from the inner loop even before this PR due to being an invalid source (e.g. physical reg).   

https://github.com/llvm/llvm-project/pull/212563


More information about the llvm-commits mailing list