Skip to content

Conversation

fmayer
Copy link
Contributor

@fmayer fmayer commented Sep 19, 2025

We would reenter the loop with %i.04 being 0, so the usub would
overflow to -1. This was the only test in this file that had
an overflow in the loop, the other ones did not.

Created using spr 1.3.4
@llvmbot
Copy link
Member

llvmbot commented Sep 19, 2025

@llvm/pr-subscribers-llvm-transforms

Author: Florian Mayer (fmayer)

Changes

We would reenter the lloop with %i.04 being 0, so the usub would
overflow to -1. That does not appear to be the intent of the test.


Full diff: https://github.com/llvm/llvm-project/pull/159683.diff

1 Files Affected:

  • (modified) llvm/test/Transforms/IndVarSimplify/X86/overflow-intrinsics.ll (+3-6)
diff --git a/llvm/test/Transforms/IndVarSimplify/X86/overflow-intrinsics.ll b/llvm/test/Transforms/IndVarSimplify/X86/overflow-intrinsics.ll
index e678146c80af8..c7db8b962f3d6 100644
--- a/llvm/test/Transforms/IndVarSimplify/X86/overflow-intrinsics.ll
+++ b/llvm/test/Transforms/IndVarSimplify/X86/overflow-intrinsics.ll
@@ -109,12 +109,9 @@ for.body:                                         ; preds = %entry, %cont
   %0 = tail call { i32, i1 } @llvm.usub.with.overflow.i32(i32 %i.04, i32 1)
   %1 = extractvalue { i32, i1 } %0, 1
 
-; It is theoretically possible to prove this, but SCEV cannot
-; represent non-unsigned-wrapping subtraction operations.
-
 ; CHECK: for.body:
-; CHECK:  [[COND:%[^ ]+]] = extractvalue { i32, i1 } %1, 1
-; CHECK-NEXT:  br i1 [[COND]], label %trap, label %cont, !nosanitize !0
+; CHECK-NOT: @llvm.usub.with.overflow.i32
+; CHECK: br i1 false, label %trap, label %cont, !nosanitize !0
   br i1 %1, label %trap, label %cont, !nosanitize !{}
 
 trap:                                             ; preds = %for.body
@@ -123,7 +120,7 @@ trap:                                             ; preds = %for.body
 
 cont:                                             ; preds = %for.body
   %2 = extractvalue { i32, i1 } %0, 0
-  %cmp = icmp sgt i32 %2, -1
+  %cmp = icmp sgt i32 %2, 0
   br i1 %cmp, label %for.body, label %for.cond.cleanup
 }
 

Created using spr 1.3.4
Created using spr 1.3.4
@fmayer fmayer changed the title [IndVarSimplify] [NFC] Fix incorrect test [IndVarSimplify] [NFC] Add non-overflowing usub test Sep 19, 2025
@fmayer fmayer requested a review from fhahn September 19, 2025 23:38
@fmayer fmayer changed the title [IndVarSimplify] [NFC] Add non-overflowing usub test [NFC] [IndVarSimplify] Add non-overflowing usub test Sep 20, 2025
Copy link
Contributor

@fhahn fhahn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

@fmayer fmayer merged commit 370e007 into main Sep 21, 2025
9 checks passed
@fmayer fmayer deleted the users/fmayer/spr/indvarsimplify-nfc-fix-incorrect-test branch September 21, 2025 19:10
@llvm-ci
Copy link
Collaborator

llvm-ci commented Sep 21, 2025

LLVM Buildbot has detected a new failure on builder clang-aarch64-sve-vla-2stage running on linaro-g3-01 while building llvm at step 12 "ninja check 2".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/41/builds/9067

Here is the relevant piece of the build log for the reference
Step 12 (ninja check 2) failure: stage 2 checked (failure)
******************** TEST 'lit :: shtest-readfile-external.py' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 4
env LIT_USE_INTERNAL_SHELL=0 not env -u FILECHECK_OPTS "/usr/bin/python3.10" /home/tcwg-buildbot/worker/clang-aarch64-sve-vla-2stage/llvm/llvm/utils/lit/lit.py -j1 --order=lexical -a -v Inputs/shtest-readfile | FileCheck -match-full-lines -DTEMP_PATH=/home/tcwg-buildbot/worker/clang-aarch64-sve-vla-2stage/stage2/utils/lit/tests/Inputs/shtest-readfile/Output /home/tcwg-buildbot/worker/clang-aarch64-sve-vla-2stage/stage2/utils/lit/tests/shtest-readfile-external.py
# executed command: env LIT_USE_INTERNAL_SHELL=0 not env -u FILECHECK_OPTS /usr/bin/python3.10 /home/tcwg-buildbot/worker/clang-aarch64-sve-vla-2stage/llvm/llvm/utils/lit/lit.py -j1 --order=lexical -a -v Inputs/shtest-readfile
# executed command: FileCheck -match-full-lines -DTEMP_PATH=/home/tcwg-buildbot/worker/clang-aarch64-sve-vla-2stage/stage2/utils/lit/tests/Inputs/shtest-readfile/Output /home/tcwg-buildbot/worker/clang-aarch64-sve-vla-2stage/stage2/utils/lit/tests/shtest-readfile-external.py
# .---command stderr------------
# | /home/tcwg-buildbot/worker/clang-aarch64-sve-vla-2stage/stage2/utils/lit/tests/shtest-readfile-external.py:22:10: error: CHECK: expected string not found in input
# | # CHECK: + echo hello bye
# |          ^
# | <stdin>:88:590: note: scanning from here
# | echo $(cat /home/tcwg-buildbot/worker/clang-aarch64-sve-vla-2stage/stage2/utils/lit/tests/Inputs/shtest-readfile/Output/two-same-line.txt.tmp.1) $(cat /home/tcwg-buildbot/worker/clang-aarch64-sve-vla-2stage/stage2/utils/lit/tests/Inputs/shtest-readfile/Output/two-same-line.txt.tmp.2) && test -e /home/tcwg-buildbot/worker/clang-aarch64-sve-vla-2stage/stage2/utils/lit/tests/Inputs/shtest-readfile/Output/two-same-line.txt.tmp.1 && test -e /home/tcwg-buildbot/worker/clang-aarch64-sve-vla-2stage/stage2/utils/lit/tests/Inputs/shtest-readfile/Output/two-same-line.txt.tmp.2 # RUN: at line 5
# |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ^
# | <stdin>:91:1: note: possible intended match here
# | + echo hello
# | ^
# | 
# | Input file: <stdin>
# | Check file: /home/tcwg-buildbot/worker/clang-aarch64-sve-vla-2stage/stage2/utils/lit/tests/shtest-readfile-external.py
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             .
# |             .
# |             .
# |            83: -- 
# |            84: echo -n "hello" > /home/tcwg-buildbot/worker/clang-aarch64-sve-vla-2stage/stage2/utils/lit/tests/Inputs/shtest-readfile/Output/two-same-line.txt.tmp.1 # RUN: at line 3 
# |            85: + echo -n hello 
# |            86: echo -n "bye" > /home/tcwg-buildbot/worker/clang-aarch64-sve-vla-2stage/stage2/utils/lit/tests/Inputs/shtest-readfile/Output/two-same-line.txt.tmp.2 # RUN: at line 4 
# |            87: + echo -n bye 
# |            88: echo $(cat /home/tcwg-buildbot/worker/clang-aarch64-sve-vla-2stage/stage2/utils/lit/tests/Inputs/shtest-readfile/Output/two-same-line.txt.tmp.1) $(cat /home/tcwg-buildbot/worker/clang-aarch64-sve-vla-2stage/stage2/utils/lit/tests/Inputs/shtest-readfile/Output/two-same-line.txt.tmp.2) && test -e /home/tcwg-buildbot/worker/clang-aarch64-sve-vla-2stage/stage2/utils/lit/tests/Inputs/shtest-readfile/Output/two-same-line.txt.tmp.1 && test -e /home/tcwg-buildbot/worker/clang-aarch64-sve-vla-2stage/stage2/utils/lit/tests/Inputs/shtest-readfile/Output/two-same-line.txt.tmp.2 # RUN: at line 5 
# | check:22'0                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  X error: no match found
# |            89: ++ cat /home/tcwg-buildbot/worker/clang-aarch64-sve-vla-2stage/stage2/utils/lit/tests/Inputs/shtest-readfile/Output/two-same-line.txt.tmp.1 
# | check:22'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            90: ++ cat /home/tcwg-buildbot/worker/clang-aarch64-sve-vla-2stage/stage2/utils/lit/tests/Inputs/shtest-readfile/Output/two-same-line.txt.tmp.2 
# | check:22'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            91: + echo hello 
# | check:22'0     ~~~~~~~~~~~~~
# | check:22'1     ?             possible intended match
# |            92: + test -e /home/tcwg-buildbot/worker/clang-aarch64-sve-vla-2stage/stage2/utils/lit/tests/Inputs/shtest-readfile/Output/two-same-line.txt.tmp.1 
# | check:22'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            93: + test -e /home/tcwg-buildbot/worker/clang-aarch64-sve-vla-2stage/stage2/utils/lit/tests/Inputs/shtest-readfile/Output/two-same-line.txt.tmp.2 
# | check:22'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |            94: not echo return # RUN: at line 8 
# | check:22'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...

ckoparkar added a commit to ckoparkar/llvm-project that referenced this pull request Sep 23, 2025
* main: (1562 commits)
  Document Policy on supporting newer C++ standard in LLVM codebase (llvm#156823)
  [MLIR][Transform][SMT] Introduce transform.smt.constrain_params (llvm#159450)
  Reapply "[compiler-rt] Remove %T from shared object substitutions (llvm#155302)"
  [NFC] [IndVarSimplify] Add non-overflowing usub test (llvm#159683)
  [Github] Remove separate tools checkout from pr-code workflows (llvm#159967)
  [clang] fix using enum redecl in template regression (llvm#159996)
  [DAG] Skip `mstore` combine for `<1 x ty>` vectors (llvm#159915)
  [mlir] Expose optional `PatternBenefit` to `func` populate functions (NFC) (llvm#159986)
  [LV] Set correct costs for interleave group members.
  [clang] ast-dump: use template pattern for `instantiated_from` (llvm#159952)
  [ARM] ha-alignstack-call.ll - regenerate test checks (llvm#159988)
  [LLD][MachO] Silence warning when building with MSVC
  [llvm][Analysis] Silence warning when building with MSVC
  [LV] Skip select cost for invariant divisors in legacy cost model.
  [Clang] Fix an error-recovery crash after d1a80de (llvm#159976)
  [VPlanPatternMatch] Introduce m_ConstantInt (llvm#159558)
  [GlobalISel] Add G_ABS computeKnownBits (llvm#154413)
  [gn build] Port 4cabd1e
  Reland "[clangd] Add feature modules registry" (llvm#154836)
  [LV] Also handle non-uniform scalarized loads when processing AddrDefs.
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants