[llvm] [InstCombine] Optimise the expression `(C && A) | (!C && B)` with `FoldOrOfLogicalAnds` (PR #178438)

via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 11 04:51:41 PST 2026


github-actions[bot] wrote:

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

* 130769 tests passed
* 2929 tests skipped
* 2 tests failed

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

### LLVM
<details>
<summary>LLVM.Transforms/InstCombine/select-safe-transforms.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\select-safe-transforms.ll -passes=instcombine -S | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe C:\_work\llvm-project\llvm-project\llvm\test\Transforms\InstCombine\select-safe-transforms.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\select-safe-transforms.ll'
# .---command stderr------------
# | C:\_work\llvm-project\llvm-project\llvm\test\Transforms\InstCombine\select-safe-transforms.ll:261:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[OR:%.*]] = select i1 [[C:%.*]], i1 [[B:%.*]], i1 [[A:%.*]], !prof [[PROF2]]
# |               ^
# | <stdin>:130:35: note: scanning from here
# | define i1 @bools_logical_commute0(i1 %a, i1 %b, i1 %c) !prof !0 {
# |                                   ^
# | <stdin>:130:35: note: with "PROF2" equal to "!2"
# | define i1 @bools_logical_commute0(i1 %a, i1 %b, i1 %c) !prof !0 {
# |                                   ^
# | <stdin>:131:2: note: possible intended match here
# |  %or = select i1 %c, i1 %b, i1 %a, !prof !3
# |  ^
# | C:\_work\llvm-project\llvm-project\llvm\test\Transforms\InstCombine\select-safe-transforms.ll:409:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[TMP1:%.*]] = freeze i1 [[C:%.*]]
# |               ^
# | <stdin>:192:35: note: scanning from here
# | define i1 @bools_logical_commute3(i1 %a, i1 %b, i1 %c) {
# |                                   ^
# | <stdin>:193:2: note: possible intended match here
# |  %or = select i1 %c, i1 %b, i1 %a
# |  ^
# | C:\_work\llvm-project\llvm-project\llvm\test\Transforms\InstCombine\select-safe-transforms.ll:612:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[TMP1:%.*]] = freeze i1 [[C:%.*]]
# |               ^
# | <stdin>:276:36: note: scanning from here
# | define i1 @bools2_logical_commute3(i1 %a, i1 %b, i1 %c) {
# |                                    ^
# | <stdin>:277:2: note: possible intended match here
# |  %or = select i1 %c, i1 %a, i1 %b
# |  ^
# | 
# | Input file: <stdin>
# | Check file: C:\_work\llvm-project\llvm-project\llvm\test\Transforms\InstCombine\select-safe-transforms.ll
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             .
# |             .
# |             .
# |           125:  %or = select i1 %b, <2 x i1> splat (i1 true), <2 x i1> %implied 
# |           126:  %and = select <2 x i1> %or, <2 x i1> %cond, <2 x i1> zeroinitializer 
# |           127:  ret <2 x i1> %and 
# |           128: } 
# |           129:  
# |           130: define i1 @bools_logical_commute0(i1 %a, i1 %b, i1 %c) !prof !0 { 
# | next:261'0                                       X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
# | next:261'1                                                                        with "PROF2" equal to "!2"
# |           131:  %or = select i1 %c, i1 %b, i1 %a, !prof !3 
# | next:261'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | next:261'2      ?                                           possible intended match
# |           132:  ret i1 %or 
# | next:261'0     ~~~~~~~~~~~~
# |           133: } 
# | next:261'0     ~~
# |           134:  
# | next:261'0     ~
# |           135: define i1 @bools_logical_commute0_and1(i1 %a, i1 %b, i1 %c) !prof !0 { 
# | next:261'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |           136:  %or = select i1 %c, i1 %b, i1 %a, !prof !1 
# |             .
# |             .
# |             .
# |           187: define <2 x i1> @bools_logical_commute2_and1_and2(<2 x i1> %a, <2 x i1> %b, <2 x i1> %c) { 
# |           188:  %or = select <2 x i1> %c, <2 x i1> %b, <2 x i1> %a 
# |           189:  ret <2 x i1> %or 
# |           190: } 
# |           191:  
# |           192: define i1 @bools_logical_commute3(i1 %a, i1 %b, i1 %c) { 
# | next:409'0                                       X~~~~~~~~~~~~~~~~~~~~~~ error: no match found
# |           193:  %or = select i1 %c, i1 %b, i1 %a 
# | next:409'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | next:409'1      ?                                 possible intended match
# |           194:  ret i1 %or 
# | next:409'0     ~~~~~~~~~~~~
# |           195: } 
# | next:409'0     ~~
# |           196:  
# | next:409'0     ~
# |           197: define i1 @bools_logical_commute3_and1(i1 %b, i1 %c) { 
# | next:409'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |           198:  %a = call i1 @gen1() 
# |             .
# |             .
# |             .
# |           271:  %b = call i1 @gen1() 
# |           272:  %or = select i1 %c, i1 %a, i1 %b 
# |           273:  ret i1 %or 
# |           274: } 
# |           275:  
# |           276: define i1 @bools2_logical_commute3(i1 %a, i1 %b, i1 %c) { 
# | next:612'0                                        X~~~~~~~~~~~~~~~~~~~~~~ error: no match found
# |           277:  %or = select i1 %c, i1 %a, i1 %b 
# | next:612'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | next:612'1      ?                                 possible intended match
# |           278:  ret i1 %or 
# | next:612'0     ~~~~~~~~~~~~
# |           279: } 
# | next:612'0     ~~
# |           280:  
# | next:612'0     ~
# |           281: define i1 @bools2_logical_commute3_nopoison(i1 %a, i1 %b, i1 noundef %c) { 
# | next:612'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |           282:  %or = select i1 %c, i1 %a, i1 %b 
# |             .
# |             .
# |             .
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

```
</details>
<details>
<summary>LLVM.Transforms/PhaseOrdering/simplifycfg-options.ll</summary>

```
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
c:\_work\llvm-project\llvm-project\build\bin\opt.exe -O1 -S < C:\_work\llvm-project\llvm-project\llvm\test\Transforms\PhaseOrdering\simplifycfg-options.ll                    | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe C:\_work\llvm-project\llvm-project\llvm\test\Transforms\PhaseOrdering\simplifycfg-options.ll
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\opt.exe' -O1 -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\simplifycfg-options.ll'
# .---command stderr------------
# | C:\_work\llvm-project\llvm-project\llvm\test\Transforms\PhaseOrdering\simplifycfg-options.ll:107:15: error: CHECK-NEXT: is not on the line after the previous match
# | ; CHECK-NEXT: [[SPEC_SELECT:%.*]] = xor i1 [[LHS:%.*]], [[RHS:%.*]]
# |               ^
# | <stdin>:50:2: note: 'next' match was here
# |  %spec.select = xor i1 %rhs, %0
# |  ^
# | <stdin>:48:11: note: previous match ended here
# | andandend:
# |           ^
# | <stdin>:49:1: note: non-matching line after previous match is here
# |  %0 = freeze i1 %lhs
# | ^
# | 
# | Input file: <stdin>
# | Check file: C:\_work\llvm-project\llvm-project\llvm\test\Transforms\PhaseOrdering\simplifycfg-options.ll
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |           .
# |           .
# |           .
# |          45:  
# |          46: ; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) 
# |          47: define i1 @PR58313(i1 %lhs, i1 %rhs) local_unnamed_addr #1 { 
# |          48: andandend: 
# |          49:  %0 = freeze i1 %lhs 
# |          50:  %spec.select = xor i1 %rhs, %0 
# | next:107      !~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  error: match on wrong line
# |          51:  ret i1 %spec.select 
# |          52: } 
# |          53:  
# |          54: attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) } 
# |          55: attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) } 
# | >>>>>>
# `-----------------------------
# 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/178438


More information about the llvm-commits mailing list