[llvm] [SeparateConstOffsetFromGEP] Fix incorrect inbounds flag in case of non-negative index but negative offset (PR #190192)

via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 2 08:53:53 PDT 2026


github-actions[bot] wrote:

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

* 133032 tests passed
* 3054 tests skipped
* 2 tests failed

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

### LLVM
<details>
<summary>LLVM.Transforms/SeparateConstOffsetFromGEP/AMDGPU/preserve-inbounds.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\SeparateConstOffsetFromGEP\AMDGPU\preserve-inbounds.ll -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1200 -passes=separate-const-offset-from-gep -S | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe C:\_work\llvm-project\llvm-project\llvm\test\Transforms\SeparateConstOffsetFromGEP\AMDGPU\preserve-inbounds.ll
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\opt.exe' -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1200 -passes=separate-const-offset-from-gep -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\SeparateConstOffsetFromGEP\AMDGPU\preserve-inbounds.ll'
# .---command stderr------------
# | C:\_work\llvm-project\llvm-project\llvm\test\Transforms\SeparateConstOffsetFromGEP\AMDGPU\preserve-inbounds.ll:44:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds i32, ptr [[P:%.*]], i64 [[IDX]]
# |               ^
# | <stdin>:24:40: note: scanning from here
# |  %idx = and i64 %i, 9223372036854775807
# |                                        ^
# | <stdin>:24:40: note: with "IDX" equal to "%idx"
# |  %idx = and i64 %i, 9223372036854775807
# |                                        ^
# | <stdin>:25:2: note: possible intended match here
# |  %0 = getelementptr i32, ptr %p, i64 %idx
# |  ^
# | 
# | Input file: <stdin>
# | Check file: C:\_work\llvm-project\llvm-project\llvm\test\Transforms\SeparateConstOffsetFromGEP\AMDGPU\preserve-inbounds.ll
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |            .
# |            .
# |            .
# |           19:  ret ptr %arrayidx2 
# |           20: } 
# |           21:  
# |           22: define ptr @sign_bit_clear(ptr %p, i64 %i) #0 { 
# |           23: entry: 
# |           24:  %idx = and i64 %i, 9223372036854775807 
# | next:44'0                                            X error: no match found
# | next:44'1                                              with "IDX" equal to "%idx"
# |           25:  %0 = getelementptr i32, ptr %p, i64 %idx 
# | next:44'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | next:44'2      ?                                         possible intended match
# |           26:  %arrayidx2 = getelementptr i8, ptr %0, i64 4 
# | next:44'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |           27:  ret ptr %arrayidx2 
# | next:44'0     ~~~~~~~~~~~~~~~~~~~~
# |           28: } 
# | next:44'0     ~~
# |           29:  
# | next:44'0     ~
# |           30: define ptr @sign_bit_not_clear(ptr %p, i64 %i) #0 { 
# | next:44'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            .
# |            .
# |            .
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

```
</details>
<details>
<summary>LLVM.Transforms/SeparateConstOffsetFromGEP/AMDGPU/reorder-gep-inbounds.ll</summary>

```
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
c:\_work\llvm-project\llvm-project\build\bin\opt.exe -mtriple=amdgcn-amd-amdhsa -mcpu=gfx90a -S -passes=separate-const-offset-from-gep < C:\_work\llvm-project\llvm-project\llvm\test\Transforms\SeparateConstOffsetFromGEP\AMDGPU\reorder-gep-inbounds.ll | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe C:\_work\llvm-project\llvm-project\llvm\test\Transforms\SeparateConstOffsetFromGEP\AMDGPU\reorder-gep-inbounds.ll
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\opt.exe' -mtriple=amdgcn-amd-amdhsa -mcpu=gfx90a -S -passes=separate-const-offset-from-gep
# 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\SeparateConstOffsetFromGEP\AMDGPU\reorder-gep-inbounds.ll'
# .---command stderr------------
# | C:\_work\llvm-project\llvm-project\llvm\test\Transforms\SeparateConstOffsetFromGEP\AMDGPU\reorder-gep-inbounds.ll:88:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds i16, ptr [[IN_PTR]], i64 [[IDXPROM]]
# |               ^
# | <stdin>:48:55: note: scanning from here
# |  %in.idx1.nneg = and i64 %in.idx1, 9223372036854775807
# |                                                       ^
# | <stdin>:48:55: note: with "IN_PTR" equal to "%in.ptr"
# |  %in.idx1.nneg = and i64 %in.idx1, 9223372036854775807
# |                                                       ^
# | <stdin>:48:55: note: with "IDXPROM" equal to "%in.idx1.nneg"
# |  %in.idx1.nneg = and i64 %in.idx1, 9223372036854775807
# |                                                       ^
# | <stdin>:49:2: note: possible intended match here
# |  %0 = getelementptr i16, ptr %in.ptr, i64 %in.idx1.nneg
# |  ^
# | C:\_work\llvm-project\llvm-project\llvm\test\Transforms\SeparateConstOffsetFromGEP\AMDGPU\reorder-gep-inbounds.ll:265:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds i128, ptr addrspace(1) [[IN_PTR]], i64 [[IN_IDX1_NNEG]]
# |               ^
# | <stdin>:136:55: note: scanning from here
# |  %in.idx1.nneg = and i64 %in.idx1, 9223372036854775807
# |                                                       ^
# | <stdin>:136:55: note: with "IN_PTR" equal to "%in.ptr"
# |  %in.idx1.nneg = and i64 %in.idx1, 9223372036854775807
# |                                                       ^
# | <stdin>:136:55: note: with "IN_IDX1_NNEG" equal to "%in.idx1.nneg"
# |  %in.idx1.nneg = and i64 %in.idx1, 9223372036854775807
# |                                                       ^
# | <stdin>:138:3: note: possible intended match here
# |  %idx11 = getelementptr i8, ptr addrspace(1) %0, i64 1024
# |   ^
# | 
# | Input file: <stdin>
# | Check file: C:\_work\llvm-project\llvm-project\llvm\test\Transforms\SeparateConstOffsetFromGEP\AMDGPU\reorder-gep-inbounds.ll
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             .
# |             .
# |             .
# |            43:  ret void 
# |            44: } 
# |            45:  
# |            46: define void @inboundsNonNegative_i8i16(ptr %in.ptr, i64 %in.idx1) #0 { 
# |            47: entry: 
# |            48:  %in.idx1.nneg = and i64 %in.idx1, 9223372036854775807 
# | next:88'0                                                            X error: no match found
# | next:88'1                                                              with "IN_PTR" equal to "%in.ptr"
# | next:88'2                                                              with "IDXPROM" equal to "%in.idx1.nneg"
# |            49:  %0 = getelementptr i16, ptr %in.ptr, i64 %in.idx1.nneg 
# | next:88'0      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | next:88'3       ?                                                       possible intended match
# |            50:  %idx11 = getelementptr i8, ptr %0, i64 1024 
# | next:88'0      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            51:  ret void 
# | next:88'0      ~~~~~~~~~~
# |            52: } 
# | next:88'0      ~~
# |            53:  
# | next:88'0      ~
# |            54: define void @inboundsNonchained_first(ptr %in.ptr, i64 %in.idx1) #0 { 
# | next:88'0      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |             .
# |             .
# |             .
# |           131:  ret void 
# |           132: } 
# |           133:  
# |           134: define void @addrspace1(ptr addrspace(1) %in.ptr, i64 %in.idx1) #0 { 
# |           135: entry: 
# |           136:  %in.idx1.nneg = and i64 %in.idx1, 9223372036854775807 
# | next:265'0                                                           X error: no match found
# | next:265'1                                                             with "IN_PTR" equal to "%in.ptr"
# | next:265'2                                                             with "IN_IDX1_NNEG" equal to "%in.idx1.nneg"
# |           137:  %0 = getelementptr i128, ptr addrspace(1) %in.ptr, i64 %in.idx1.nneg 
# | next:265'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |           138:  %idx11 = getelementptr i8, ptr addrspace(1) %0, i64 1024 
# | next:265'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | next:265'3       ?                                                        possible intended match
# |           139:  ret void 
# | next:265'0     ~~~~~~~~~~
# |           140: } 
# | next:265'0     ~~
# |           141:  
# | next:265'0     ~
# |           142: define void @addrspace3(ptr addrspace(3) %in.ptr, i64 %in.idx1) #0 { 
# | next:265'0     ~~~~~~~~~~~~~~~~~~~~~~~~
# |           143: entry: 
# |             .
# |             .
# |             .
# | >>>>>>
# `-----------------------------
# 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/190192


More information about the llvm-commits mailing list