[llvm] [InstCombine] Handle sext/zext of i1 "selects" in canonicalizeClampLike (PR #227067)

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 29 02:58:04 PDT 2026


github-actions[bot] wrote:

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

* 142884 tests passed
* 3384 tests skipped
* 1 test failed

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

### LLVM
<details>
<summary>LLVM.Transforms/InstCombine/truncating-saturate.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\truncating-saturate.ll -passes=instcombine -S | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe C:\_work\llvm-project\llvm-project\llvm\test\Transforms\InstCombine\truncating-saturate.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\truncating-saturate.ll'
# .---command stderr------------
# | C:\_work\llvm-project\llvm-project\llvm\test\Transforms\InstCombine\truncating-saturate.ll:786:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.smin.i32(i32 [[TMP0]], i32 255)
# |               ^
# | <stdin>:363:45: note: scanning from here
# |  %0 = call i32 @llvm.smax.i32(i32 %x, i32 0)
# |                                             ^
# | <stdin>:363:45: note: with "TMP0" equal to "%0"
# |  %0 = call i32 @llvm.smax.i32(i32 %x, i32 0)
# |                                             ^
# | <stdin>:363:45: note: pattern attempts to capture variables: "TMP1"
# |  %0 = call i32 @llvm.smax.i32(i32 %x, i32 0)
# |                                             ^
# | <stdin>:364:4: note: possible intended match here
# |  %trunc1 = call i32 @llvm.umin.i32(i32 %0, i32 255)
# |    ^
# | C:\_work\llvm-project\llvm-project\llvm\test\Transforms\InstCombine\truncating-saturate.ll:803:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[TMP1:%.*]] = call i64 @llvm.smin.i64(i64 [[TMP0]], i64 65535)
# |               ^
# | <stdin>:371:45: note: scanning from here
# |  %0 = call i64 @llvm.smax.i64(i64 %x, i64 0)
# |                                             ^
# | <stdin>:371:45: note: with "TMP0" equal to "%0"
# |  %0 = call i64 @llvm.smax.i64(i64 %x, i64 0)
# |                                             ^
# | <stdin>:371:45: note: pattern attempts to capture variables: "TMP1"
# |  %0 = call i64 @llvm.smax.i64(i64 %x, i64 0)
# |                                             ^
# | <stdin>:372:4: note: possible intended match here
# |  %trunc1 = call i64 @llvm.umin.i64(i64 %0, i64 65535)
# |    ^
# | C:\_work\llvm-project\llvm-project\llvm\test\Transforms\InstCombine\truncating-saturate.ll:819:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i32 [[X:%.*]], 256
# |               ^
# | <stdin>:378:7: note: scanning from here
# | entry:
# |       ^
# | <stdin>:378:7: note: pattern attempts to capture variables: "CMP", "X"
# | entry:
# |       ^
# | <stdin>:379:2: note: possible intended match here
# |  %0 = icmp sgt i32 %x, 256
# |  ^
# | 
# | Input file: <stdin>
# | Check file: C:\_work\llvm-project\llvm-project\llvm\test\Transforms\InstCombine\truncating-saturate.ll
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             .
# |             .
# |             .
# |           358:  ret <4 x i8> %trunc 
# |           359: } 
# |           360:  
# |           361: define i8 @clamp_i32_to_i8_swapped(i32 %x) { 
# |           362: entry: 
# |           363:  %0 = call i32 @llvm.smax.i32(i32 %x, i32 0) 
# | next:786'0                                                {   search range start (exclusive)
# | next:786'1                                                    error: no match found in search range
# | next:786'2                                                    with "TMP0" equal to "%0"
# | next:786'3                                                    pattern attempts to capture variables: "TMP1"
# |           364:  %trunc1 = call i32 @llvm.umin.i32(i32 %0, i32 255) 
# | next:786'4        ?                                                  possible intended match
# |           365:  %trunc = trunc nuw i32 %trunc1 to i8 
# |           366:  ret i8 %trunc 
# |           367: } 
# |           368:  
# |           369: define i16 @clamp_i64_to_i16_swapped(i64 %x) { 
# | next:786'5                                          }           search range end (exclusive)
# |           370: entry: 
# |           371:  %0 = call i64 @llvm.smax.i64(i64 %x, i64 0) 
# | next:803'0                                                {   search range start (exclusive)
# | next:803'1                                                    error: no match found in search range
# | next:803'2                                                    with "TMP0" equal to "%0"
# | next:803'3                                                    pattern attempts to capture variables: "TMP1"
# |           372:  %trunc1 = call i64 @llvm.umin.i64(i64 %0, i64 65535) 
# | next:803'4        ?                                                    possible intended match
# |           373:  %trunc = trunc nuw i64 %trunc1 to i16 
# |           374:  ret i16 %trunc 
# |           375: } 
# |           376:  
# |           377: define i8 @no_clamp_i32_to_i8_swapped_wrong_const(i32 %x) { 
# | next:803'5                                                       }           search range end (exclusive)
# |           378: entry: 
# | next:819'0          {   search range start (exclusive)
# | next:819'1              error: no match found in search range
# | next:819'2              pattern attempts to capture variables: "CMP", "X"
# |           379:  %0 = icmp sgt i32 %x, 256 
# | next:819'3      ?                           possible intended match
# |           380:  %1 = call i32 @llvm.smax.i32(i32 %x, i32 0) 
# |           381:  %2 = trunc i32 %1 to i8 
# |           382:  %trunc = select i1 %0, i8 -1, i8 %2 
# |           383:  ret i8 %trunc 
# |           384: } 
# |           385:  
# |           386: define i8 @no_clamp_i32_to_i8_swapped_wrong_arms(i32 %x) { 
# | next:819'4                                                      }           search range end (exclusive)
# |           387: entry: 
# |           388:  %cmp = icmp ugt i32 %x, 255 
# |           389:  %0 = icmp sgt i32 %x, 0 
# |           390:  %shr = sext i1 %0 to i32 
# |           391:  %cond = select i1 %cmp, i32 %x, i32 %shr 
# |             .
# |             .
# |             .
# | >>>>>>
# `-----------------------------
# 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/227067


More information about the llvm-commits mailing list