[llvm] [SelectionDAG] Fix condition used for unsigned subtraction overflow (PR #170896)

via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 11 08:11:27 PST 2025


github-actions[bot] wrote:

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

* 128570 tests passed
* 2805 tests skipped
* 3 tests failed

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

### LLVM
<details>
<summary>LLVM.CodeGen/AMDGPU/carryout-selection.ll</summary>

```
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
c:\_work\llvm-project\llvm-project\build\bin\llc.exe -mtriple=amdgcn -stop-after=amdgpu-isel < C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\AMDGPU\carryout-selection.ll | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe -enable-var-scope -check-prefixes=GCN-ISEL                C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\AMDGPU\carryout-selection.ll
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\llc.exe' -mtriple=amdgcn -stop-after=amdgpu-isel
# note: command had no output on stdout or stderr
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe' -enable-var-scope -check-prefixes=GCN-ISEL 'C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\AMDGPU\carryout-selection.ll'
# .---command stderr------------
# | C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\AMDGPU\carryout-selection.ll:1678:13: error: GCN-ISEL: expected string not found in input
# | ; GCN-ISEL: S_USUBO_PSEUDO
# |             ^
# | <stdin>:2683:6: note: scanning from here
# |  bb.0 (%ir-block.0):
# |      ^
# | <stdin>:2710:18: note: possible intended match here
# |  %34:sreg_64 = S_SUB_U64_PSEUDO %28, %31, implicit-def dead $scc
# |                  ^
# | C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\AMDGPU\carryout-selection.ll:1824:13: error: GCN-ISEL: expected string not found in input
# | ; GCN-ISEL: V_SUB_CO_U32_e64
# |             ^
# | <stdin>:2858:6: note: scanning from here
# |  bb.0 (%ir-block.0):
# |      ^
# | <stdin>:2884:22: note: possible intended match here
# |  %32:sreg_64_xexec = V_CMP_GT_U64_e64 %29, %31, implicit $exec
# |                      ^
# | 
# | Input file: <stdin>
# | Check file: C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\AMDGPU\carryout-selection.ll
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |               .
# |               .
# |               .
# |            2678:  dynamicVGPRBlockSize: 0 
# |            2679:  scratchReservedForDynamicVGPRs: 0 
# |            2680:  numKernargPreloadSGPRs: 0 
# |            2681:  isWholeWaveFunction: false 
# |            2682: body: | 
# |            2683:  bb.0 (%ir-block.0): 
# | check:1678'0          X~~~~~~~~~~~~~~~ error: no match found
# |            2684:  liveins: $sgpr4_sgpr5 
# | check:1678'0     ~~~~~~~~~~~~~~~~~~~~~~~
# |            2685:   
# | check:1678'0     ~~
# |            2686:  %5:sgpr_64(p4) = COPY $sgpr4_sgpr5 
# | check:1678'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            2687:  %11:sgpr_256 = S_LOAD_DWORDX8_IMM %5(p4), 9, 0 :: (dereferenceable invariant load (s256) from %ir.out.kernarg.offset, align 4, addrspace 4) 
# | check:1678'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            2688:  %12:sreg_32 = COPY %11.sub1 
# | check:1678'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |               .
# |               .
# |               .
# |            2705:  %29:sreg_32 = COPY %11.sub7 
# | check:1678'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            2706:  %30:sreg_32 = COPY %11.sub6 
# | check:1678'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            2707:  %31:sreg_64 = REG_SEQUENCE killed %30, %subreg.sub0, killed %29, %subreg.sub1 
# | check:1678'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            2708:  %33:vreg_64 = COPY %31 
# | check:1678'0     ~~~~~~~~~~~~~~~~~~~~~~~~
# |            2709:  %32:sreg_64_xexec = V_CMP_GT_U64_e64 %28, %33, implicit $exec 
# | check:1678'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            2710:  %34:sreg_64 = S_SUB_U64_PSEUDO %28, %31, implicit-def dead $scc 
# | check:1678'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | check:1678'1                      ?                                                possible intended match
# |            2711:  %35:vreg_64 = COPY %34 
# | check:1678'0     ~~~~~~~~~~~~~~~~~~~~~~~~
# |            2712:  BUFFER_STORE_DWORDX2_OFFSET killed %35, killed %19, 0, 0, 0, 0, implicit $exec :: (store (s64) into %ir.2, addrspace 1) 
# | check:1678'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            2713:  %36:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, killed %32, implicit $exec 
# | check:1678'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            2714:  BUFFER_STORE_BYTE_OFFSET killed %36, killed %25, 0, 0, 0, 0, implicit $exec :: (store (s8) into %ir.3, addrspace 1) 
# | check:1678'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            2715:  S_ENDPGM 0 
# | check:1678'0     ~~~~~~~~~~~~
# |               .
# |               .
# |               .
# |            2853:  dynamicVGPRBlockSize: 0 
# |            2854:  scratchReservedForDynamicVGPRs: 0 
# |            2855:  numKernargPreloadSGPRs: 0 
# |            2856:  isWholeWaveFunction: false 
# |            2857: body: | 
# |            2858:  bb.0 (%ir-block.0): 
# | check:1824'0          X~~~~~~~~~~~~~~~ error: no match found
# |            2859:  liveins: $vgpr0, $sgpr4_sgpr5 
# | check:1824'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            2860:   
# | check:1824'0     ~~
# |            2861:  %5:sgpr_64(p4) = COPY $sgpr4_sgpr5 
# | check:1824'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            2862:  %0:vgpr_32(s32) = COPY $vgpr0 
# | check:1824'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            2863:  %11:sgpr_128 = S_LOAD_DWORDX4_IMM %5(p4), 9, 0 :: (dereferenceable invariant load (s128) from %ir.out.kernarg.offset, align 4, addrspace 4) 
# | check:1824'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |               .
# |               .
# |               .
# |            2879:  %27:sreg_32 = COPY %25.sub0 
# | check:1824'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            2880:  %28:sgpr_128 = REG_SEQUENCE killed %27, %subreg.sub0, killed %26, %subreg.sub1, %23, %subreg.sub2, %22, %subreg.sub3 
# | check:1824'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            2881:  %29:sreg_64 = REG_SEQUENCE killed %14, %subreg.sub0, killed %13, %subreg.sub1 
# | check:1824'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            2882:  %30:vgpr_32 = V_MOV_B32_e32 0, implicit $exec 
# | check:1824'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            2883:  %31:vreg_64 = REG_SEQUENCE %0(s32), %subreg.sub0, killed %30, %subreg.sub1 
# | check:1824'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            2884:  %32:sreg_64_xexec = V_CMP_GT_U64_e64 %29, %31, implicit $exec 
# | check:1824'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | check:1824'1                          ?                                          possible intended match
# |            2885:  %33:vreg_64 = V_SUB_U64_PSEUDO %29, %31, implicit-def dead $vcc, implicit $exec 
# | check:1824'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            2886:  BUFFER_STORE_DWORDX2_OFFSET killed %33, killed %24, 0, 0, 0, 0, implicit $exec :: (store (s64) into %ir.2, addrspace 1) 
# | check:1824'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            2887:  %34:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, killed %32, implicit $exec 
# | check:1824'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            2888:  BUFFER_STORE_BYTE_OFFSET killed %34, killed %28, 0, 0, 0, 0, implicit $exec :: (store (s8) into %ir.3, addrspace 1) 
# | check:1824'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            2889:  S_ENDPGM 0 
# | check:1824'0     ~~~~~~~~~~~~
# |               .
# |               .
# |               .
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

```
</details>
<details>
<summary>LLVM.CodeGen/AMDGPU/carryout-selection.s</summary>

```
Test has no 'RUN:' line
```
</details>
<details>
<summary>LLVM.CodeGen/X86/uadd_sat.ll</summary>

```
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
c:\_work\llvm-project\llvm-project\build\bin\llc.exe < C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\X86\uadd_sat.ll -mtriple=i686 -mattr=cmov | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\X86\uadd_sat.ll --check-prefix=X86
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\llc.exe' -mtriple=i686 -mattr=cmov
# 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\CodeGen\X86\uadd_sat.ll' --check-prefix=X86
# note: command had no output on stdout or stderr
# RUN: at line 3
c:\_work\llvm-project\llvm-project\build\bin\llc.exe < C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\X86\uadd_sat.ll -mtriple=x86_64-linux | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\X86\uadd_sat.ll --check-prefix=X64
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\llc.exe' -mtriple=x86_64-linux
# 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\CodeGen\X86\uadd_sat.ll' --check-prefix=X64
# .---command stderr------------
# | C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\X86\uadd_sat.ll:154:13: error: X64-NEXT: expected string not found in input
# | ; X64-NEXT: movdqa %xmm0, %xmm3
# |             ^
# | <stdin>:82:85: note: scanning from here
# |  movdqa .LCPI5_0(%rip), %xmm2 # xmm2 = [2147483648,2147483648,2147483648,2147483648]
# |                                                                                     ^
# | <stdin>:85:3: note: possible intended match here
# |  pxor %xmm0, %xmm2
# |   ^
# | 
# | Input file: <stdin>
# | Check file: C:\_work\llvm-project\llvm-project\llvm\test\CodeGen\X86\uadd_sat.ll
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             .
# |             .
# |             .
# |            77:  .globl vec 
# |            78:  .p2align 4 
# |            79:  .type vec, at function 
# |            80: vec: # @vec 
# |            81: # %bb.0: 
# |            82:  movdqa .LCPI5_0(%rip), %xmm2 # xmm2 = [2147483648,2147483648,2147483648,2147483648] 
# | next:154'0                                                                                         X error: no match found
# |            83:  paddd %xmm1, %xmm0 
# | next:154'0     ~~~~~~~~~~~~~~~~~~~~
# |            84:  pxor %xmm2, %xmm1 
# | next:154'0     ~~~~~~~~~~~~~~~~~~~
# |            85:  pxor %xmm0, %xmm2 
# | next:154'0     ~~~~~~~~~~~~~~~~~~~
# | next:154'1       ?                 possible intended match
# |            86:  pcmpgtd %xmm2, %xmm1 
# | next:154'0     ~~~~~~~~~~~~~~~~~~~~~~
# |            87:  por %xmm1, %xmm0 
# | next:154'0     ~~~~~~~~~~~~~~~~~~
# |            88:  retq 
# | next:154'0     ~~~~~~
# |            89: .Lfunc_end5: 
# | next:154'0     ~~~~~~~~~~~~~
# |            90:  .size vec, .Lfunc_end5-vec 
# | next:154'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             .
# |             .
# |             .
# | >>>>>>
# `-----------------------------
# 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/170896


More information about the llvm-commits mailing list