Skip to content

Reapply "[VPlan] Remove manual region removal when simplifying for VF and UF. (#181252)"#188589

Merged
fhahn merged 1 commit into
llvm:mainfrom
fhahn:recommit-manual-region-removal
Mar 26, 2026
Merged

Reapply "[VPlan] Remove manual region removal when simplifying for VF and UF. (#181252)"#188589
fhahn merged 1 commit into
llvm:mainfrom
fhahn:recommit-manual-region-removal

Conversation

@fhahn

@fhahn fhahn commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

This reverts commit e30f9c1.

Re-land, now that the reported crash causing the revert has been fixed as part of 77fb848 (#187504).

Original message:

Replace manual region dissolution code in
simplifyBranchConditionForVFAndUF with using general removeBranchOnConst. simplifyBranchConditionForVFAndUF now just creates a (BranchOnCond true) or updates BranchOnTwoConds.

The loop then gets automatically removed by running removeBranchOnConst.

This removes a bunch of special logic to handle header phi replacements and CFG updates. With the new code, there's no restriction on what kind of header phi recipes the loop contains.

Note that VPEVLBasedIVRecipe needs to be marked as readnone. This is technically unrelated, but I could not find an independent test that would be impacted.

The code to deal with epilogue resume values now needs updating, because we may simplify a reduction directly to the start value.

PR: #181252

@fhahn fhahn added the skip-precommit-approval PR for CI feedback, not intended for review label Mar 25, 2026
@fhahn fhahn enabled auto-merge (squash) March 25, 2026 20:16
@github-actions

Copy link
Copy Markdown

🐧 Linux x64 Test Results

  • 171775 tests passed
  • 3076 tests skipped
  • 1 test failed

Failed Tests

(click on a test name to see its output)

LLVM

LLVM.Transforms/PhaseOrdering/ARM/arm_var_q31.ll
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/opt < /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/Transforms/PhaseOrdering/ARM/arm_var_q31.ll -passes="default<O3>" -S | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/Transforms/PhaseOrdering/ARM/arm_var_q31.ll
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/opt '-passes=default<O3>' -S
# note: command had no output on stdout or stderr
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/Transforms/PhaseOrdering/ARM/arm_var_q31.ll
# .---command stderr------------
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/Transforms/PhaseOrdering/ARM/arm_var_q31.ll:77:10: error: CHECK: expected string not found in input
# | ; CHECK: while.body.preheader67:
# |          ^
# | <stdin>:76:72: note: scanning from here
# |  br i1 %cmp.n, label %while.end.loopexit, label %while.body.preheader63
# |                                                                        ^
# | <stdin>:78:1: note: possible intended match here
# | while.body.preheader63: ; preds = %while.body.preheader, %middle.block
# | ^
# | 
# | Input file: <stdin>
# | Check file: /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/Transforms/PhaseOrdering/ARM/arm_var_q31.ll
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             .
# |             .
# |             .
# |            71:  %34 = icmp eq i32 %index.next, %n.vec 
# |            72:  br i1 %34, label %middle.block, label %vector.body, !llvm.loop !8 
# |            73:  
# |            74: middle.block: ; preds = %vector.body 
# |            75:  %cmp.n = icmp eq i32 %shr, %n.vec 
# |            76:  br i1 %cmp.n, label %while.end.loopexit, label %while.body.preheader63 
# | check:77'0                                                                            X error: no match found
# |            77:  
# | check:77'0     ~
# |            78: while.body.preheader63: ; preds = %while.body.preheader, %middle.block 
# | check:77'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | check:77'1     ?                                                                       possible intended match
# |            79:  %sumOfSquares.043.ph = phi i64 [ 0, %while.body.preheader ], [ %25, %middle.block ] 
# | check:77'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            80:  %pSrc.addr.042.ph = phi ptr [ %pSrc, %while.body.preheader ], [ %1, %middle.block ] 
# | check:77'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            81:  %blkCnt.041.ph = phi i32 [ %shr, %while.body.preheader ], [ %2, %middle.block ] 
# | check:77'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            82:  %sum.040.ph = phi i64 [ 0, %while.body.preheader ], [ %33, %middle.block ] 
# | check:77'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            83:  br label %while.body 
# | check:77'0     ~~~~~~~~~~~~~~~~~~~~~~
# |             .
# |             .
# |             .
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the infrastructure label.

@github-actions

Copy link
Copy Markdown

🪟 Windows x64 Test Results

  • 132716 tests passed
  • 3031 tests skipped
  • 1 test failed

Failed Tests

(click on a test name to see its output)

LLVM

LLVM.Transforms/PhaseOrdering/ARM/arm_var_q31.ll
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
c:\_work\llvm-project\llvm-project\build\bin\opt.exe < C:\_work\llvm-project\llvm-project\llvm\test\Transforms\PhaseOrdering\ARM\arm_var_q31.ll -passes="default<O3>" -S | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe C:\_work\llvm-project\llvm-project\llvm\test\Transforms\PhaseOrdering\ARM\arm_var_q31.ll
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\opt.exe' '-passes=default<O3>' -S
# note: command had no output on stdout or stderr
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe' 'C:\_work\llvm-project\llvm-project\llvm\test\Transforms\PhaseOrdering\ARM\arm_var_q31.ll'
# .---command stderr------------
# | C:\_work\llvm-project\llvm-project\llvm\test\Transforms\PhaseOrdering\ARM\arm_var_q31.ll:77:10: error: CHECK: expected string not found in input
# | ; CHECK: while.body.preheader67:
# |          ^
# | <stdin>:76:72: note: scanning from here
# |  br i1 %cmp.n, label %while.end.loopexit, label %while.body.preheader63
# |                                                                        ^
# | <stdin>:78:1: note: possible intended match here
# | while.body.preheader63: ; preds = %while.body.preheader, %middle.block
# | ^
# | 
# | Input file: <stdin>
# | Check file: C:\_work\llvm-project\llvm-project\llvm\test\Transforms\PhaseOrdering\ARM\arm_var_q31.ll
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             .
# |             .
# |             .
# |            71:  %34 = icmp eq i32 %index.next, %n.vec 
# |            72:  br i1 %34, label %middle.block, label %vector.body, !llvm.loop !8 
# |            73:  
# |            74: middle.block: ; preds = %vector.body 
# |            75:  %cmp.n = icmp eq i32 %shr, %n.vec 
# |            76:  br i1 %cmp.n, label %while.end.loopexit, label %while.body.preheader63 
# | check:77'0                                                                            X error: no match found
# |            77:  
# | check:77'0     ~
# |            78: while.body.preheader63: ; preds = %while.body.preheader, %middle.block 
# | check:77'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | check:77'1     ?                                                                       possible intended match
# |            79:  %sumOfSquares.043.ph = phi i64 [ 0, %while.body.preheader ], [ %25, %middle.block ] 
# | check:77'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            80:  %pSrc.addr.042.ph = phi ptr [ %pSrc, %while.body.preheader ], [ %1, %middle.block ] 
# | check:77'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            81:  %blkCnt.041.ph = phi i32 [ %shr, %while.body.preheader ], [ %2, %middle.block ] 
# | check:77'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            82:  %sum.040.ph = phi i64 [ 0, %while.body.preheader ], [ %33, %middle.block ] 
# | check:77'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            83:  br label %while.body 
# | check:77'0     ~~~~~~~~~~~~~~~~~~~~~~
# |             .
# |             .
# |             .
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the infrastructure label.

… and UF. (llvm#181252)"

This reverts commit e30f9c1.

Re-land, now that the reported crash causing the revert has been fixed
as part of 77fb848 (llvm#187504).

Original message:

Replace manual region dissolution code in
simplifyBranchConditionForVFAndUF with using general
removeBranchOnConst. simplifyBranchConditionForVFAndUF now just creates
a (BranchOnCond true) or updates BranchOnTwoConds.

The loop then gets automatically removed by running removeBranchOnConst.

This removes a bunch of special logic to handle header phi replacements
and CFG updates. With the new code, there's no restriction on what kind
of header phi recipes the loop contains.

Note that VPEVLBasedIVRecipe needs to be marked as readnone. This is
technically unrelated, but I could not find an independent test that
would be impacted.

The code to deal with epilogue resume values now needs updating, because
we may simplify a reduction directly to the start value.

PR: llvm#181252
@fhahn fhahn force-pushed the recommit-manual-region-removal branch from 538f7bb to e4a7cbf Compare March 26, 2026 09:41
@fhahn fhahn merged commit 40304d8 into llvm:main Mar 26, 2026
9 of 10 checks passed
@llvm-ci

llvm-ci commented Mar 26, 2026

Copy link
Copy Markdown

LLVM Buildbot has detected a new failure on builder openmp-s390x-linux running on systemz-1 while building llvm at step 6 "test-openmp".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/88/builds/21795

Here is the relevant piece of the build log for the reference
Step 6 (test-openmp) failure: test (failure)
******************** TEST 'libomp :: tasking/issue-94260-2.c' FAILED ********************
Exit Code: -11

Command Output (stdout):
--
# RUN: at line 1
/home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/./bin/clang -fopenmp   -I /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -I /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test -L /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/src  -fno-omit-frame-pointer -mbackchain -I /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test/ompt /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test/tasking/issue-94260-2.c -o /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/test/tasking/Output/issue-94260-2.c.tmp -lm -latomic && /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/test/tasking/Output/issue-94260-2.c.tmp
# executed command: /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/./bin/clang -fopenmp -I /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -I /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test -L /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -fno-omit-frame-pointer -mbackchain -I /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test/ompt /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test/tasking/issue-94260-2.c -o /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/test/tasking/Output/issue-94260-2.c.tmp -lm -latomic
# executed command: /home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/test/tasking/Output/issue-94260-2.c.tmp
# note: command had no output on stdout or stderr
# error: command failed with exit status: -11

--

********************


@fhahn fhahn deleted the recommit-manual-region-removal branch March 27, 2026 09:35
Aadarsh-Keshri pushed a commit to Aadarsh-Keshri/llvm-project that referenced this pull request Mar 28, 2026
… and UF. (llvm#181252)" (llvm#188589)

This reverts commit e30f9c1.

Re-land, now that the reported crash causing the revert has been fixed
as part of 77fb848 (llvm#187504).

Original message:

Replace manual region dissolution code in
simplifyBranchConditionForVFAndUF with using general
removeBranchOnConst. simplifyBranchConditionForVFAndUF now just creates
a (BranchOnCond true) or updates BranchOnTwoConds.

The loop then gets automatically removed by running removeBranchOnConst.

This removes a bunch of special logic to handle header phi replacements
and CFG updates. With the new code, there's no restriction on what kind
of header phi recipes the loop contains.

Note that VPEVLBasedIVRecipe needs to be marked as readnone. This is
technically unrelated, but I could not find an independent test that
would be impacted.

The code to deal with epilogue resume values now needs updating, because
we may simplify a reduction directly to the start value.

PR: llvm#181252
fzou1 pushed a commit to fzou1/llvm-project that referenced this pull request Mar 30, 2026
… and UF. (llvm#181252)" (llvm#188589)

This reverts commit e30f9c1.

Re-land, now that the reported crash causing the revert has been fixed
as part of 77fb848 (llvm#187504).

Original message:

Replace manual region dissolution code in
simplifyBranchConditionForVFAndUF with using general
removeBranchOnConst. simplifyBranchConditionForVFAndUF now just creates
a (BranchOnCond true) or updates BranchOnTwoConds.

The loop then gets automatically removed by running removeBranchOnConst.

This removes a bunch of special logic to handle header phi replacements
and CFG updates. With the new code, there's no restriction on what kind
of header phi recipes the loop contains.

Note that VPEVLBasedIVRecipe needs to be marked as readnone. This is
technically unrelated, but I could not find an independent test that
would be impacted.

The code to deal with epilogue resume values now needs updating, because
we may simplify a reduction directly to the start value.

PR: llvm#181252
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants