[llvm] Do not speculate select when it fails to simplify phi nodes. (PR #218159)

via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 22 14:04:28 PDT 2026


github-actions[bot] wrote:

<!--PREMERGE ADVISOR COMMENT: Windows-->
# :window: Windows x64 Test Results

* 140191 tests passed
* 3727 tests skipped
* 2 tests failed

## Failed Tests
(click on a test name to see its output)

### LLVM
<details>
<summary>LLVM.Transforms/LoopUnroll/ARM/upperbound.ll</summary>

```
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
c:\_work\llvm-project\llvm-project\build\bin\opt.exe -passes=loop-unroll,simplifycfg,instcombine,simplifycfg -switch-range-to-icmp -S -mtriple arm-none-eabi -mcpu=cortex-m7 C:\_work\llvm-project\llvm-project\llvm\test\Transforms\LoopUnroll\ARM\upperbound.ll | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe C:\_work\llvm-project\llvm-project\llvm\test\Transforms\LoopUnroll\ARM\upperbound.ll
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\opt.exe' -passes=loop-unroll,simplifycfg,instcombine,simplifycfg -switch-range-to-icmp -S -mtriple arm-none-eabi -mcpu=cortex-m7 'C:\_work\llvm-project\llvm-project\llvm\test\Transforms\LoopUnroll\ARM\upperbound.ll'
# 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\LoopUnroll\ARM\upperbound.ll'
# .---command stderr------------
# | C:\_work\llvm-project\llvm-project\llvm\test\Transforms\LoopUnroll\ARM\upperbound.ll:77:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[SWITCH:%.*]] = icmp ult i32 [[L86_OFF]], 24
# |               ^
# | <stdin>:58:29: note: scanning from here
# |  %l86.off = add i32 %l86, -1
# |                             ^
# | <stdin>:58:29: note: with "L86_OFF" equal to "%l86.off"
# |  %l86.off = add i32 %l86, -1
# |                             ^
# | <stdin>:58:29: note: pattern attempts to capture variables: "SWITCH"
# |  %l86.off = add i32 %l86, -1
# |                             ^
# | <stdin>:59:4: note: possible intended match here
# |  %switch = icmp ult i32 %l86.off, 25
# |    ^
# | 
# | Input file: <stdin>
# | Check file: C:\_work\llvm-project\llvm-project\llvm\test\Transforms\LoopUnroll\ARM\upperbound.ll
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |            .
# |            .
# |            .
# |           53:  ret void 
# |           54: } 
# |           55:  
# |           56: define i32 @test2(i32 %l86) #0 { 
# |           57: entry: 
# |           58:  %l86.off = add i32 %l86, -1 
# | next:77'0                                {   search range start (exclusive)
# | next:77'1                                    error: no match found in search range
# | next:77'2                                    with "L86_OFF" equal to "%l86.off"
# | next:77'3                                    pattern attempts to capture variables: "SWITCH"
# |           59:  %switch = icmp ult i32 %l86.off, 25 
# | next:77'4        ?                                   possible intended match
# |           60:  %spec.select = select i1 %switch, i32 0, i32 1 
# |           61:  ret i32 %spec.select 
# |           62: } 
# |           63:  
# |           64: attributes #0 = { "target-cpu"="cortex-m7" } 
# | next:77'5                                                  } search range end (exclusive)
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

```
</details>
<details>
<summary>LLVM.Transforms/SimplifyCFG/ARM/select-costs.ll</summary>

```
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
c:\_work\llvm-project\llvm-project\build\bin\opt.exe -mtriple=thumbv8.1m.main -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S C:\_work\llvm-project\llvm-project\llvm\test\Transforms\SimplifyCFG\ARM\select-costs.ll -o - | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe C:\_work\llvm-project\llvm-project\llvm\test\Transforms\SimplifyCFG\ARM\select-costs.ll --check-prefix=V8M
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\opt.exe' -mtriple=thumbv8.1m.main -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S 'C:\_work\llvm-project\llvm-project\llvm\test\Transforms\SimplifyCFG\ARM\select-costs.ll' -o -
# 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\SimplifyCFG\ARM\select-costs.ll' --check-prefix=V8M
# .---command stderr------------
# | C:\_work\llvm-project\llvm-project\llvm\test\Transforms\SimplifyCFG\ARM\select-costs.ll:20:13: error: V8M-NEXT: expected string not found in input
# | ; V8M-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[UGT_9]], i1 false, i1 true
# |             ^
# | <stdin>:15:37: note: scanning from here
# |  %ugt.9 = icmp ugt i8 %c.off.i150, 9
# |                                     ^
# | <stdin>:15:37: note: with "UGT_9" equal to "%ugt.9"
# |  %ugt.9 = icmp ugt i8 %c.off.i150, 9
# |                                     ^
# | <stdin>:15:37: note: pattern attempts to capture variables: "SPEC_SELECT"
# |  %ugt.9 = icmp ugt i8 %c.off.i150, 9
# |                                     ^
# | <stdin>:23:48: note: possible intended match here
# |  %cmp = phi i1 [ true, %select.unfold198 ], [ false, %sw.bb92 ], [ false, %entry ]
# |                                                ^
# | 
# | Input file: <stdin>
# | Check file: C:\_work\llvm-project\llvm-project\llvm\test\Transforms\SimplifyCFG\ARM\select-costs.ll
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |            .
# |            .
# |            .
# |           10:  %zero = icmp ne i8 %in, 0 
# |           11:  br i1 %zero, label %for.inc.preheader, label %sw.bb92 
# |           12:  
# |           13: sw.bb92: ; preds = %for.body, %entry 
# |           14:  %c.off.i150 = add i8 %in, -48 
# |           15:  %ugt.9 = icmp ugt i8 %c.off.i150, 9 
# | next:20'0                                        {   search range start (exclusive)
# | next:20'1                                            error: no match found in search range
# | next:20'2                                            with "UGT_9" equal to "%ugt.9"
# | next:20'3                                            pattern attempts to capture variables: "SPEC_SELECT"
# |           16:  br i1 %ugt.9, label %for.inc.preheader, label %select.unfold198 
# |           17:  
# |           18: select.unfold198: ; preds = %sw.bb92 
# |           19:  br label %for.inc.preheader 
# |           20:  
# |           21: for.inc.preheader: ; preds = %select.unfold198, %sw.bb92, %entry 
# |           22:  %str.ph.0 = phi ptr [ %incdec.ptr109.c4, %select.unfold198 ], [ %incdec.ptr109.c4, %sw.bb92 ], [ %gep.a.2, %entry ] 
# |           23:  %cmp = phi i1 [ true, %select.unfold198 ], [ false, %sw.bb92 ], [ false, %entry ] 
# | next:20'4                                                    ?                                     possible intended match
# |           24:  %phi.res = phi i32 [ 7, %select.unfold198 ], [ 1, %sw.bb92 ], [ 1, %entry ] 
# |           25:  br label %for.inc 
# |           26:  
# |           27: for.inc: ; preds = %for.body, %for.inc.preheader 
# |           28:  %str.ph.1 = phi ptr [ %incdec.ptr109, %for.body ], [ %str.ph.0, %for.inc.preheader ] 
# |            .
# |            .
# |            .
# |           39: exit: ; preds = %for.inc 
# |           40:  ret i32 %phi.res 
# |           41: } 
# |           42:  
# |           43: ; Function Attrs: minsize optsize 
# |           44: define i32 @multiple_spec_select_costs_minsize(ptr %a, ptr %idx, i8 %in) #0 { 
# | next:20'5                                                    }                                search range end (exclusive)
# |           45: entry: 
# |           46:  %gep.a.2 = getelementptr inbounds i8, ptr %a, i32 2 
# |           47:  %incdec.ptr109.c4 = getelementptr inbounds i8, ptr %a, i32 3 
# |           48:  %zero = icmp ne i8 %in, 0 
# |           49:  br i1 %zero, label %for.inc.preheader, label %sw.bb92 
# |            .
# |            .
# |            .
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

```
</details>

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.

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


More information about the llvm-commits mailing list