[llvm] [InstCombine] Fold `icmp samesign u{gt/lt} (X +nsw C2), C` -> `icmp s{gt/lt} X, (C - C2)` (PR #169960)

via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 30 10:50:21 PST 2025


github-actions[bot] wrote:

<!--PREMERGE ADVISOR COMMENT: Linux-->
# :penguin: Linux x64 Test Results

* 166454 tests passed
* 2872 tests skipped
* 1 test failed

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

### LLVM
<details>
<summary>LLVM.Transforms/InstCombine/remove-loop-phi-multiply-by-zero.ll</summary>

```
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 2
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/opt < /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/Transforms/InstCombine/remove-loop-phi-multiply-by-zero.ll -passes=instcombine -S | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/Transforms/InstCombine/remove-loop-phi-multiply-by-zero.ll
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/opt -passes=instcombine -S
# note: command had no output on stdout or stderr
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/Transforms/InstCombine/remove-loop-phi-multiply-by-zero.ll
# .---command stderr------------
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/Transforms/InstCombine/remove-loop-phi-multiply-by-zero.ll:212:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i64 [[I_02]], 999
# |               ^
# | <stdin>:117:33: note: scanning from here
# |  %inc = add nuw nsw i64 %i.02, 1
# |                                 ^
# | <stdin>:117:33: note: with "I_02" equal to "%i.02"
# |  %inc = add nuw nsw i64 %i.02, 1
# |                                 ^
# | <stdin>:118:2: note: possible intended match here
# |  %cmp = icmp slt i64 %i.02, 999
# |  ^
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/Transforms/InstCombine/remove-loop-phi-multiply-by-zero.ll:251:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i64 [[I_02]], 999
# |               ^
# | <stdin>:138:33: note: scanning from here
# |  %inc = add nuw nsw i64 %i.02, 1
# |                                 ^
# | <stdin>:138:33: note: with "I_02" equal to "%i.02"
# |  %inc = add nuw nsw i64 %i.02, 1
# |                                 ^
# | <stdin>:139:2: note: possible intended match here
# |  %cmp = icmp slt i64 %i.02, 999
# |  ^
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/Transforms/InstCombine/remove-loop-phi-multiply-by-zero.ll:358:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i64 [[I_02]], 999
# |               ^
# | <stdin>:195:33: note: scanning from here
# |  %inc = add nuw nsw i64 %i.02, 1
# |                                 ^
# | <stdin>:195:33: note: with "I_02" equal to "%i.02"
# |  %inc = add nuw nsw i64 %i.02, 1
# |                                 ^
# | <stdin>:196:2: note: possible intended match here
# |  %cmp = icmp slt i64 %i.02, 999
# |  ^
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/Transforms/InstCombine/remove-loop-phi-multiply-by-zero.ll:397:15: error: CHECK-NEXT: expected string not found in input
# | ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i64 [[I_02]], 999
# |               ^
# | <stdin>:216:33: note: scanning from here
# |  %inc = add nuw nsw i64 %i.02, 1
# |                                 ^
# | <stdin>:216:33: note: with "I_02" equal to "%i.02"
# |  %inc = add nuw nsw i64 %i.02, 1
# |                                 ^
# | <stdin>:217:2: note: possible intended match here
# |  %cmp = icmp slt i64 %i.02, 999
# |  ^
# | 
# | Input file: <stdin>
# | Check file: /home/gha/actions-runner/_work/llvm-project/llvm-project/llvm/test/Transforms/InstCombine/remove-loop-phi-multiply-by-zero.ll
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             .
# |             .
# |             .
# |           112:  %i.02 = phi i64 [ 0, %entry ], [ 0, %entry_2 ], [ %inc, %for.body ] 
# |           113:  %f_prod.01 = phi double [ 0.000000e+00, %entry ], [ 0.000000e+00, %entry_2 ], [ %mul, %for.body ] 
# |           114:  %arrayidx = getelementptr inbounds nuw double, ptr %arr_d, i64 %i.02 
# |           115:  %0 = load double, ptr %arrayidx, align 8 
# |           116:  %mul = fmul fast double %f_prod.01, %0 
# |           117:  %inc = add nuw nsw i64 %i.02, 1 
# | next:212'0                                     X error: no match found
# | next:212'1                                       with "I_02" equal to "%i.02"
# |           118:  %cmp = icmp slt i64 %i.02, 999 
# | next:212'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | next:212'2      ?                               possible intended match
# |           119:  br i1 %cmp, label %for.body, label %end 
# | next:212'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |           120:  
# | next:212'0     ~
# |           121: end: ; preds = %for.body 
# | next:212'0     ~~~~~~~~~~~~~~~~~~~~~~~~~
# |           122:  ret double %mul 
# | next:212'0     ~~~~~~~~~~~~~~~~~
# |           123: } 
# | next:212'0     ~~
# |             .
# |             .
# |             .
# |           133:  %i.02 = phi i64 [ 0, %entry ], [ 0, %entry_2 ], [ %inc, %for.body ] 
# |           134:  %f_prod.01 = phi double [ 1.000000e+00, %entry ], [ 0.000000e+00, %entry_2 ], [ %mul, %for.body ] 
# |           135:  %arrayidx = getelementptr inbounds nuw double, ptr %arr_d, i64 %i.02 
# |           136:  %0 = load double, ptr %arrayidx, align 8 
# |           137:  %mul = fmul fast double %f_prod.01, %0 
# |           138:  %inc = add nuw nsw i64 %i.02, 1 
# | next:251'0                                     X error: no match found
# | next:251'1                                       with "I_02" equal to "%i.02"
# |           139:  %cmp = icmp slt i64 %i.02, 999 
# | next:251'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | next:251'2      ?                               possible intended match
# |           140:  br i1 %cmp, label %for.body, label %end 
# | next:251'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |           141:  
# | next:251'0     ~
# |           142: end: ; preds = %for.body 
# | next:251'0     ~~~~~~~~~~~~~~~~~~~~~~~~~
# |           143:  ret double %mul 
# | next:251'0     ~~~~~~~~~~~~~~~~~
# |           144: } 
# | next:251'0     ~~
# |             .
# |             .
# |             .
# |           190:  %i.02 = phi i64 [ 0, %entry ], [ 0, %entry_2 ], [ %inc, %for.body ] 
# |           191:  %f_prod.01 = phi i32 [ 0, %entry ], [ 0, %entry_2 ], [ %mul, %for.body ] 
# |           192:  %arrayidx = getelementptr inbounds nuw i32, ptr %arr_d, i64 %i.02 
# |           193:  %0 = load i32, ptr %arrayidx, align 4 
# |           194:  %mul = mul i32 %f_prod.01, %0 
# |           195:  %inc = add nuw nsw i64 %i.02, 1 
# | next:358'0                                     X error: no match found
# | next:358'1                                       with "I_02" equal to "%i.02"
# |           196:  %cmp = icmp slt i64 %i.02, 999 
# | next:358'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | next:358'2      ?                               possible intended match
# |           197:  br i1 %cmp, label %for.body, label %end 
# | next:358'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |           198:  
# | next:358'0     ~
# |           199: end: ; preds = %for.body 
# | next:358'0     ~~~~~~~~~~~~~~~~~~~~~~~~~
# |           200:  ret i32 %mul 
# | next:358'0     ~~~~~~~~~~~~~~
# |           201: } 
# | next:358'0     ~~
# |             .
# |             .
# |             .
# |           211:  %i.02 = phi i64 [ 0, %entry ], [ 0, %entry_2 ], [ %inc, %for.body ] 
# |           212:  %f_prod.01 = phi i32 [ 0, %entry ], [ 1, %entry_2 ], [ %mul, %for.body ] 
# |           213:  %arrayidx = getelementptr inbounds nuw i32, ptr %arr_d, i64 %i.02 
# |           214:  %0 = load i32, ptr %arrayidx, align 4 
# |           215:  %mul = mul i32 %f_prod.01, %0 
# |           216:  %inc = add nuw nsw i64 %i.02, 1 
# | next:397'0                                     X error: no match found
# | next:397'1                                       with "I_02" equal to "%i.02"
# |           217:  %cmp = icmp slt i64 %i.02, 999 
# | next:397'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | next:397'2      ?                               possible intended match
# |           218:  br i1 %cmp, label %for.body, label %end 
# | next:397'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |           219:  
# | next:397'0     ~
# |           220: end: ; preds = %for.body 
# | next:397'0     ~~~~~~~~~~~~~~~~~~~~~~~~~
# |           221:  ret i32 %mul 
# | next:397'0     ~~~~~~~~~~~~~~
# |           222: } 
# | next:397'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/169960


More information about the llvm-commits mailing list