[llvm] [instcombine] fold range checks for bitwise and/or (PR #176642)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 19 10:37:10 PST 2026


github-actions[bot] wrote:

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

* 129599 tests passed
* 2871 tests skipped
* 3 tests failed

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

### LLVM
<details>
<summary>LLVM.Transforms/InstCombine/and2.ll</summary>

```
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\InstCombine\and2.ll -passes=instcombine -S | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe C:\_work\llvm-project\llvm-project\llvm\test\Transforms\InstCombine\and2.ll
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\opt.exe' -passes=instcombine -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\InstCombine\and2.ll'
# .---command stderr------------
# | C:\_work\llvm-project\llvm-project\llvm\test\Transforms\InstCombine\and2.ll:37:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[AND2:%.*]] = and i1 [[TMP1]], [[B:%.*]]
# |               ^
# | <stdin>:20:24: note: scanning from here
# |  %1 = icmp eq i32 %i, 0
# |                        ^
# | <stdin>:20:24: note: with "TMP1" equal to "%1"
# |  %1 = icmp eq i32 %i, 0
# |                        ^
# | <stdin>:21:2: note: possible intended match here
# |  %and2 = and i1 %b, %1
# |  ^
# | 
# | Input file: <stdin>
# | Check file: C:\_work\llvm-project\llvm-project\llvm\test\Transforms\InstCombine\and2.ll
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |            .
# |            .
# |            .
# |           15:  %a = and i32 %X, %Y 
# |           16:  ret i32 %a 
# |           17: } 
# |           18:  
# |           19: define i1 @test7(i32 %i, i1 %b) { 
# |           20:  %1 = icmp eq i32 %i, 0 
# | next:37'0                            X error: no match found
# | next:37'1                              with "TMP1" equal to "%1"
# |           21:  %and2 = and i1 %b, %1 
# | next:37'0     ~~~~~~~~~~~~~~~~~~~~~~~
# | next:37'2      ?                      possible intended match
# |           22:  ret i1 %and2 
# | next:37'0     ~~~~~~~~~~~~~~
# |           23: } 
# | next:37'0     ~~
# |           24:  
# | next:37'0     ~
# |           25: define i1 @test7_logical(i32 %i, i1 %b) { 
# | next:37'0     ~~~~~~~~~~~~~~~~~~~~~~~~~
# |           26:  %1 = icmp eq i32 %i, 0 
# |            .
# |            .
# |            .
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

```
</details>
<details>
<summary>LLVM.Transforms/InstCombine/range-check-and-form.ll</summary>

```
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\InstCombine\range-check-and-form.ll -passes=instcombine -S | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe C:\_work\llvm-project\llvm-project\llvm\test\Transforms\InstCombine\range-check-and-form.ll
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\opt.exe' -passes=instcombine -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\InstCombine\range-check-and-form.ll'
# .---command stderr------------
# | C:\_work\llvm-project\llvm-project\llvm\test\Transforms\InstCombine\range-check-and-form.ll:50:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[SEL2:%.*]] = and i1 [[TMP2]], [[COND:%.*]]
# |               ^
# | <stdin>:20:31: note: scanning from here
# |  %2 = icmp ult i32 %1, 1048576
# |                               ^
# | <stdin>:20:31: note: with "TMP2" equal to "%2"
# |  %2 = icmp ult i32 %1, 1048576
# |                               ^
# | <stdin>:21:2: note: possible intended match here
# |  %sel2 = and i1 %cond, %2
# |  ^
# | 
# | Input file: <stdin>
# | Check file: C:\_work\llvm-project\llvm-project\llvm\test\Transforms\InstCombine\range-check-and-form.ll
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |            .
# |            .
# |            .
# |           15:  ret i1 %sel2 
# |           16: } 
# |           17:  
# |           18: define i1 @test_and_form_swapped(i1 %cond, i32 %y) { 
# |           19:  %1 = add i32 %y, -65536 
# |           20:  %2 = icmp ult i32 %1, 1048576 
# | next:50'0                                   X error: no match found
# | next:50'1                                     with "TMP2" equal to "%2"
# |           21:  %sel2 = and i1 %cond, %2 
# | next:50'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~
# | next:50'2      ?                         possible intended match
# |           22:  ret i1 %sel2 
# | next:50'0     ~~~~~~~~~~~~~~
# |           23: } 
# | next:50'0     ~~
# |           24:  
# | next:50'0     ~
# |           25: define i1 @test_or_form(i1 %cond, i32 %y) { 
# | next:50'0     ~~~~~~~~~~~~~~~~~~~~~~~~
# |           26:  %1 = add i32 %y, -1114112 
# |            .
# |            .
# |            .
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

```
</details>
<details>
<summary>LLVM.Transforms/InstCombine/signed-truncation-check.ll</summary>

```
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\InstCombine\signed-truncation-check.ll -passes=instcombine -S | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe C:\_work\llvm-project\llvm-project\llvm\test\Transforms\InstCombine\signed-truncation-check.ll
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\opt.exe' -passes=instcombine -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\InstCombine\signed-truncation-check.ll'
# .---command stderr------------
# | C:\_work\llvm-project\llvm-project\llvm\test\Transforms\InstCombine\signed-truncation-check.ll:145:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[T5:%.*]] = and i1 [[T5_SIMPLIFIED]], [[Z:%.*]]
# |               ^
# | <stdin>:45:41: note: scanning from here
# |  %t5.simplified = icmp ult i32 %arg, 128
# |                                         ^
# | <stdin>:45:41: note: with "T5_SIMPLIFIED" equal to "%t5.simplified"
# |  %t5.simplified = icmp ult i32 %arg, 128
# |                                         ^
# | <stdin>:46:2: note: possible intended match here
# |  %t5 = and i1 %z, %t5.simplified
# |  ^
# | C:\_work\llvm-project\llvm-project\llvm\test\Transforms\InstCombine\signed-truncation-check.ll:159:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[T5:%.*]] = select i1 [[DOTSIMPLIFIED]], i1 [[Z:%.*]], i1 false
# |               ^
# | <stdin>:51:29: note: scanning from here
# |  %1 = icmp ult i32 %arg, 128
# |                             ^
# | <stdin>:51:29: note: with "DOTSIMPLIFIED" equal to "%1"
# |  %1 = icmp ult i32 %arg, 128
# |                             ^
# | <stdin>:52:2: note: possible intended match here
# |  %t5 = select i1 %z, i1 %1, i1 false
# |  ^
# | 
# | Input file: <stdin>
# | Check file: C:\_work\llvm-project\llvm-project\llvm\test\Transforms\InstCombine\signed-truncation-check.ll
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             .
# |             .
# |             .
# |            40:  %t4.simplified = icmp ult i32 %arg, 128 
# |            41:  ret i1 %t4.simplified 
# |            42: } 
# |            43:  
# |            44: define i1 @positive_with_extra_and(i32 %arg, i1 %z) { 
# |            45:  %t5.simplified = icmp ult i32 %arg, 128 
# | next:145'0                                             X error: no match found
# | next:145'1                                               with "T5_SIMPLIFIED" equal to "%t5.simplified"
# |            46:  %t5 = and i1 %z, %t5.simplified 
# | next:145'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | next:145'2      ?                                possible intended match
# |            47:  ret i1 %t5 
# | next:145'0     ~~~~~~~~~~~~
# |            48: } 
# | next:145'0     ~~
# |            49:  
# | next:145'0     ~
# |            50: define i1 @positive_with_extra_and_logical(i32 %arg, i1 %z) { 
# | next:145'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            51:  %1 = icmp ult i32 %arg, 128 
# | next:159'0                                 X error: no match found
# | next:159'1                                   with "DOTSIMPLIFIED" equal to "%1"
# |            52:  %t5 = select i1 %z, i1 %1, i1 false 
# | next:159'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | next:159'2      ?                                    possible intended match
# |            53:  ret i1 %t5 
# | next:159'0     ~~~~~~~~~~~~
# |            54: } 
# | next:159'0     ~~
# |            55:  
# | next:159'0     ~
# |            56: define <2 x i1> @positive_vec_splat(<2 x i32> %arg) { 
# | next:159'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            57:  %t4.simplified = icmp ult <2 x i32> %arg, splat (i32 128) 
# |             .
# |             .
# |             .
# | >>>>>>
# `-----------------------------
# 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/176642


More information about the llvm-commits mailing list