Skip to content

Conversation

@andjo403
Copy link
Contributor

Many trunc nuw conditions is implied/implies icmp instructions.

Proof: https://alive2.llvm.org/ce/z/oqQyxC

cc #134093

@andjo403 andjo403 requested review from dtcxzyw and nikic May 26, 2025 20:39
@llvmbot llvmbot added llvm:instcombine Covers the InstCombine, InstSimplify and AggressiveInstCombine passes llvm:analysis Includes value tracking, cost tables and constant folding llvm:transforms labels May 26, 2025
@llvmbot
Copy link
Member

llvmbot commented May 26, 2025

@llvm/pr-subscribers-llvm-transforms

Author: Andreas Jonson (andjo403)

Changes

Many trunc nuw conditions is implied/implies icmp instructions.

Proof: https://alive2.llvm.org/ce/z/oqQyxC

cc #134093


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

2 Files Affected:

  • (modified) llvm/lib/Analysis/ValueTracking.cpp (+23-10)
  • (modified) llvm/test/Transforms/InstCombine/select-safe-impliedcond-transforms.ll (+82)
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 5b9338b500ecc..b7084cf3619f3 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -9165,15 +9165,13 @@ isImpliedCondCommonOperandWithCR(CmpPredicate LPred, const ConstantRange &LCR,
 /// is true.  Return false if LHS implies RHS is false. Otherwise, return
 /// std::nullopt if we can't infer anything.
 static std::optional<bool>
-isImpliedCondICmps(const ICmpInst *LHS, CmpPredicate RPred, const Value *R0,
-                   const Value *R1, const DataLayout &DL, bool LHSIsTrue) {
-  Value *L0 = LHS->getOperand(0);
-  Value *L1 = LHS->getOperand(1);
-
+isImpliedCondICmps(CmpPredicate LPred, const Value *L0, const Value *L1,
+                   CmpPredicate RPred, const Value *R0, const Value *R1,
+                   const DataLayout &DL, bool LHSIsTrue) {
   // The rest of the logic assumes the LHS condition is true.  If that's not the
   // case, invert the predicate to make it so.
-  CmpPredicate LPred =
-      LHSIsTrue ? LHS->getCmpPredicate() : LHS->getInverseCmpPredicate();
+  if (!LHSIsTrue)
+    LPred = ICmpInst::getInverseCmpPredicate(LPred);
 
   // We can have non-canonical operands, so try to normalize any common operand
   // to L0/R0.
@@ -9314,9 +9312,15 @@ llvm::isImpliedCondition(const Value *LHS, CmpPredicate RHSPred,
     LHSIsTrue = !LHSIsTrue;
 
   // Both LHS and RHS are icmps.
-  const ICmpInst *LHSCmp = dyn_cast<ICmpInst>(LHS);
-  if (LHSCmp)
-    return isImpliedCondICmps(LHSCmp, RHSPred, RHSOp0, RHSOp1, DL, LHSIsTrue);
+  if (const auto *LHSCmp = dyn_cast<ICmpInst>(LHS))
+    return isImpliedCondICmps(LHSCmp->getCmpPredicate(), LHSCmp->getOperand(0),
+                              LHSCmp->getOperand(1), RHSPred, RHSOp0, RHSOp1,
+                              DL, LHSIsTrue);
+  const Value *V;
+  if (match(LHS, m_NUWTrunc(m_Value(V))))
+    return isImpliedCondICmps(CmpInst::ICMP_NE, V,
+                              ConstantInt::get(V->getType(), 0), RHSPred,
+                              RHSOp0, RHSOp1, DL, LHSIsTrue);
 
   /// The LHS should be an 'or', 'and', or a 'select' instruction.  We expect
   /// the RHS to be an icmp.
@@ -9354,6 +9358,15 @@ std::optional<bool> llvm::isImpliedCondition(const Value *LHS, const Value *RHS,
     return std::nullopt;
   }
 
+  const Value *V;
+  if (match(RHS, m_NUWTrunc(m_Value(V)))) {
+    if (auto Implied = isImpliedCondition(LHS, CmpInst::ICMP_NE, V,
+                                          ConstantInt::get(V->getType(), 0), DL,
+                                          LHSIsTrue, Depth))
+      return InvertRHS ? !*Implied : *Implied;
+    return std::nullopt;
+  }
+
   if (Depth == MaxAnalysisRecursionDepth)
     return std::nullopt;
 
diff --git a/llvm/test/Transforms/InstCombine/select-safe-impliedcond-transforms.ll b/llvm/test/Transforms/InstCombine/select-safe-impliedcond-transforms.ll
index 4b66b71773683..ba34930dc14c1 100644
--- a/llvm/test/Transforms/InstCombine/select-safe-impliedcond-transforms.ll
+++ b/llvm/test/Transforms/InstCombine/select-safe-impliedcond-transforms.ll
@@ -176,3 +176,85 @@ define i1 @a_false_implies_b_false2_comm(i8 %z, i1 %X, i1 %Y) {
   %res = or i1 %sel, %a
   ret i1 %res
 }
+
+define i1 @trunc_nuw_implies_icmp_eq(i8 %x, i1 %c) {
+; CHECK-LABEL: @trunc_nuw_implies_icmp_eq(
+; CHECK-NEXT:    [[TRUNC:%.*]] = trunc nuw i8 [[X:%.*]] to i1
+; CHECK-NEXT:    [[SEL2:%.*]] = select i1 [[TRUNC]], i1 true, i1 [[C:%.*]]
+; CHECK-NEXT:    ret i1 [[SEL2]]
+;
+  %trunc = trunc nuw i8 %x to i1
+  %cmp = icmp eq i8 %x, 0
+  %sel1 = select i1 %cmp, i1 %c, i1 false
+  %sel2 = select i1 %trunc, i1 true, i1 %sel1
+  ret i1 %sel2
+}
+
+define i1 @icmp_eq_implies_trunc_nuw(i8 %x, i1 %c) {
+; CHECK-LABEL: @icmp_eq_implies_trunc_nuw(
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i8 [[X:%.*]], 0
+; CHECK-NEXT:    [[SEL2:%.*]] = select i1 [[CMP]], i1 true, i1 [[C:%.*]]
+; CHECK-NEXT:    ret i1 [[SEL2]]
+;
+  %trunc = trunc nuw i8 %x to i1
+  %cmp = icmp eq i8 %x, 0
+  %sel1 = select i1 %trunc, i1 %c, i1 false
+  %sel2 = select i1 %cmp, i1 true, i1 %sel1
+  ret i1 %sel2
+}
+
+define <2 x i1>  @trunc_nuw_implies_icmp_eq_vec(<2 x i8>  %x, <2 x i1> %c) {
+; CHECK-LABEL: @trunc_nuw_implies_icmp_eq_vec(
+; CHECK-NEXT:    [[TRUNC:%.*]] = trunc nuw <2 x i8> [[X:%.*]] to <2 x i1>
+; CHECK-NEXT:    [[SEL2:%.*]] = select <2 x i1> [[TRUNC]], <2 x i1> splat (i1 true), <2 x i1> [[C:%.*]]
+; CHECK-NEXT:    ret <2 x i1> [[SEL2]]
+;
+  %trunc = trunc nuw <2 x i8>  %x to <2 x i1>
+  %cmp = icmp eq <2 x i8>  %x, splat (i8 0)
+  %sel1 = select <2 x i1> %cmp, <2 x i1> %c, <2 x i1> splat (i1 false)
+  %sel2 = select <2 x i1> %trunc, <2 x i1> splat (i1 true), <2 x i1> %sel1
+  ret <2 x i1> %sel2
+}
+
+define <2 x i1>  @icmp_eq_implies_trunc_nuw_vec(<2 x i8>  %x, <2 x i1> %c) {
+; CHECK-LABEL: @icmp_eq_implies_trunc_nuw_vec(
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq <2 x i8> [[X:%.*]], zeroinitializer
+; CHECK-NEXT:    [[SEL2:%.*]] = select <2 x i1> [[CMP]], <2 x i1> splat (i1 true), <2 x i1> [[C:%.*]]
+; CHECK-NEXT:    ret <2 x i1> [[SEL2]]
+;
+  %trunc = trunc nuw <2 x i8>  %x to <2 x i1>
+  %cmp = icmp eq <2 x i8>  %x, splat (i8 0)
+  %sel1 = select <2 x i1> %trunc, <2 x i1> %c, <2 x i1> splat (i1 false)
+  %sel2 = select <2 x i1> %cmp, <2 x i1> splat (i1 true), <2 x i1> %sel1
+  ret <2 x i1> %sel2
+}
+
+define i1 @neg_trunc_implies_icmp_eq(i8 %x, i1 %c) {
+; CHECK-LABEL: @neg_trunc_implies_icmp_eq(
+; CHECK-NEXT:    [[TRUNC:%.*]] = trunc i8 [[X:%.*]] to i1
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i8 [[X]], 0
+; CHECK-NEXT:    [[SEL1:%.*]] = select i1 [[CMP]], i1 [[C:%.*]], i1 false
+; CHECK-NEXT:    [[SEL2:%.*]] = select i1 [[TRUNC]], i1 true, i1 [[SEL1]]
+; CHECK-NEXT:    ret i1 [[SEL2]]
+;
+  %trunc = trunc i8 %x to i1
+  %cmp = icmp eq i8 %x, 0
+  %sel1 = select i1 %cmp, i1 %c, i1 false
+  %sel2 = select i1 %trunc, i1 true, i1 %sel1
+  ret i1 %sel2
+}
+
+define i1 @neg_icmp_eq_implies_trunc(i8 %x, i1 %c) {
+; CHECK-LABEL: @neg_icmp_eq_implies_trunc(
+; CHECK-NEXT:    [[TRUNC:%.*]] = trunc i8 [[X:%.*]] to i1
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i8 [[X]], 0
+; CHECK-NEXT:    [[SEL1:%.*]] = select i1 [[TRUNC]], i1 [[C:%.*]], i1 false
+; CHECK-NEXT:    [[SEL2:%.*]] = select i1 [[CMP]], i1 true, i1 [[SEL1]]
+; CHECK-NEXT:    ret i1 [[SEL2]]
+;
+  %trunc = trunc i8 %x to i1
+  %cmp = icmp eq i8 %x, 0
+  %sel1 = select i1 %trunc, i1 %c, i1 false
+  %sel2 = select i1 %cmp, i1 true, i1 %sel1
+  ret i1 %sel2
+}

@llvmbot
Copy link
Member

llvmbot commented May 26, 2025

@llvm/pr-subscribers-llvm-analysis

Author: Andreas Jonson (andjo403)

Changes

Many trunc nuw conditions is implied/implies icmp instructions.

Proof: https://alive2.llvm.org/ce/z/oqQyxC

cc #134093


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

2 Files Affected:

  • (modified) llvm/lib/Analysis/ValueTracking.cpp (+23-10)
  • (modified) llvm/test/Transforms/InstCombine/select-safe-impliedcond-transforms.ll (+82)
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 5b9338b500ecc..b7084cf3619f3 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -9165,15 +9165,13 @@ isImpliedCondCommonOperandWithCR(CmpPredicate LPred, const ConstantRange &LCR,
 /// is true.  Return false if LHS implies RHS is false. Otherwise, return
 /// std::nullopt if we can't infer anything.
 static std::optional<bool>
-isImpliedCondICmps(const ICmpInst *LHS, CmpPredicate RPred, const Value *R0,
-                   const Value *R1, const DataLayout &DL, bool LHSIsTrue) {
-  Value *L0 = LHS->getOperand(0);
-  Value *L1 = LHS->getOperand(1);
-
+isImpliedCondICmps(CmpPredicate LPred, const Value *L0, const Value *L1,
+                   CmpPredicate RPred, const Value *R0, const Value *R1,
+                   const DataLayout &DL, bool LHSIsTrue) {
   // The rest of the logic assumes the LHS condition is true.  If that's not the
   // case, invert the predicate to make it so.
-  CmpPredicate LPred =
-      LHSIsTrue ? LHS->getCmpPredicate() : LHS->getInverseCmpPredicate();
+  if (!LHSIsTrue)
+    LPred = ICmpInst::getInverseCmpPredicate(LPred);
 
   // We can have non-canonical operands, so try to normalize any common operand
   // to L0/R0.
@@ -9314,9 +9312,15 @@ llvm::isImpliedCondition(const Value *LHS, CmpPredicate RHSPred,
     LHSIsTrue = !LHSIsTrue;
 
   // Both LHS and RHS are icmps.
-  const ICmpInst *LHSCmp = dyn_cast<ICmpInst>(LHS);
-  if (LHSCmp)
-    return isImpliedCondICmps(LHSCmp, RHSPred, RHSOp0, RHSOp1, DL, LHSIsTrue);
+  if (const auto *LHSCmp = dyn_cast<ICmpInst>(LHS))
+    return isImpliedCondICmps(LHSCmp->getCmpPredicate(), LHSCmp->getOperand(0),
+                              LHSCmp->getOperand(1), RHSPred, RHSOp0, RHSOp1,
+                              DL, LHSIsTrue);
+  const Value *V;
+  if (match(LHS, m_NUWTrunc(m_Value(V))))
+    return isImpliedCondICmps(CmpInst::ICMP_NE, V,
+                              ConstantInt::get(V->getType(), 0), RHSPred,
+                              RHSOp0, RHSOp1, DL, LHSIsTrue);
 
   /// The LHS should be an 'or', 'and', or a 'select' instruction.  We expect
   /// the RHS to be an icmp.
@@ -9354,6 +9358,15 @@ std::optional<bool> llvm::isImpliedCondition(const Value *LHS, const Value *RHS,
     return std::nullopt;
   }
 
+  const Value *V;
+  if (match(RHS, m_NUWTrunc(m_Value(V)))) {
+    if (auto Implied = isImpliedCondition(LHS, CmpInst::ICMP_NE, V,
+                                          ConstantInt::get(V->getType(), 0), DL,
+                                          LHSIsTrue, Depth))
+      return InvertRHS ? !*Implied : *Implied;
+    return std::nullopt;
+  }
+
   if (Depth == MaxAnalysisRecursionDepth)
     return std::nullopt;
 
diff --git a/llvm/test/Transforms/InstCombine/select-safe-impliedcond-transforms.ll b/llvm/test/Transforms/InstCombine/select-safe-impliedcond-transforms.ll
index 4b66b71773683..ba34930dc14c1 100644
--- a/llvm/test/Transforms/InstCombine/select-safe-impliedcond-transforms.ll
+++ b/llvm/test/Transforms/InstCombine/select-safe-impliedcond-transforms.ll
@@ -176,3 +176,85 @@ define i1 @a_false_implies_b_false2_comm(i8 %z, i1 %X, i1 %Y) {
   %res = or i1 %sel, %a
   ret i1 %res
 }
+
+define i1 @trunc_nuw_implies_icmp_eq(i8 %x, i1 %c) {
+; CHECK-LABEL: @trunc_nuw_implies_icmp_eq(
+; CHECK-NEXT:    [[TRUNC:%.*]] = trunc nuw i8 [[X:%.*]] to i1
+; CHECK-NEXT:    [[SEL2:%.*]] = select i1 [[TRUNC]], i1 true, i1 [[C:%.*]]
+; CHECK-NEXT:    ret i1 [[SEL2]]
+;
+  %trunc = trunc nuw i8 %x to i1
+  %cmp = icmp eq i8 %x, 0
+  %sel1 = select i1 %cmp, i1 %c, i1 false
+  %sel2 = select i1 %trunc, i1 true, i1 %sel1
+  ret i1 %sel2
+}
+
+define i1 @icmp_eq_implies_trunc_nuw(i8 %x, i1 %c) {
+; CHECK-LABEL: @icmp_eq_implies_trunc_nuw(
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i8 [[X:%.*]], 0
+; CHECK-NEXT:    [[SEL2:%.*]] = select i1 [[CMP]], i1 true, i1 [[C:%.*]]
+; CHECK-NEXT:    ret i1 [[SEL2]]
+;
+  %trunc = trunc nuw i8 %x to i1
+  %cmp = icmp eq i8 %x, 0
+  %sel1 = select i1 %trunc, i1 %c, i1 false
+  %sel2 = select i1 %cmp, i1 true, i1 %sel1
+  ret i1 %sel2
+}
+
+define <2 x i1>  @trunc_nuw_implies_icmp_eq_vec(<2 x i8>  %x, <2 x i1> %c) {
+; CHECK-LABEL: @trunc_nuw_implies_icmp_eq_vec(
+; CHECK-NEXT:    [[TRUNC:%.*]] = trunc nuw <2 x i8> [[X:%.*]] to <2 x i1>
+; CHECK-NEXT:    [[SEL2:%.*]] = select <2 x i1> [[TRUNC]], <2 x i1> splat (i1 true), <2 x i1> [[C:%.*]]
+; CHECK-NEXT:    ret <2 x i1> [[SEL2]]
+;
+  %trunc = trunc nuw <2 x i8>  %x to <2 x i1>
+  %cmp = icmp eq <2 x i8>  %x, splat (i8 0)
+  %sel1 = select <2 x i1> %cmp, <2 x i1> %c, <2 x i1> splat (i1 false)
+  %sel2 = select <2 x i1> %trunc, <2 x i1> splat (i1 true), <2 x i1> %sel1
+  ret <2 x i1> %sel2
+}
+
+define <2 x i1>  @icmp_eq_implies_trunc_nuw_vec(<2 x i8>  %x, <2 x i1> %c) {
+; CHECK-LABEL: @icmp_eq_implies_trunc_nuw_vec(
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq <2 x i8> [[X:%.*]], zeroinitializer
+; CHECK-NEXT:    [[SEL2:%.*]] = select <2 x i1> [[CMP]], <2 x i1> splat (i1 true), <2 x i1> [[C:%.*]]
+; CHECK-NEXT:    ret <2 x i1> [[SEL2]]
+;
+  %trunc = trunc nuw <2 x i8>  %x to <2 x i1>
+  %cmp = icmp eq <2 x i8>  %x, splat (i8 0)
+  %sel1 = select <2 x i1> %trunc, <2 x i1> %c, <2 x i1> splat (i1 false)
+  %sel2 = select <2 x i1> %cmp, <2 x i1> splat (i1 true), <2 x i1> %sel1
+  ret <2 x i1> %sel2
+}
+
+define i1 @neg_trunc_implies_icmp_eq(i8 %x, i1 %c) {
+; CHECK-LABEL: @neg_trunc_implies_icmp_eq(
+; CHECK-NEXT:    [[TRUNC:%.*]] = trunc i8 [[X:%.*]] to i1
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i8 [[X]], 0
+; CHECK-NEXT:    [[SEL1:%.*]] = select i1 [[CMP]], i1 [[C:%.*]], i1 false
+; CHECK-NEXT:    [[SEL2:%.*]] = select i1 [[TRUNC]], i1 true, i1 [[SEL1]]
+; CHECK-NEXT:    ret i1 [[SEL2]]
+;
+  %trunc = trunc i8 %x to i1
+  %cmp = icmp eq i8 %x, 0
+  %sel1 = select i1 %cmp, i1 %c, i1 false
+  %sel2 = select i1 %trunc, i1 true, i1 %sel1
+  ret i1 %sel2
+}
+
+define i1 @neg_icmp_eq_implies_trunc(i8 %x, i1 %c) {
+; CHECK-LABEL: @neg_icmp_eq_implies_trunc(
+; CHECK-NEXT:    [[TRUNC:%.*]] = trunc i8 [[X:%.*]] to i1
+; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i8 [[X]], 0
+; CHECK-NEXT:    [[SEL1:%.*]] = select i1 [[TRUNC]], i1 [[C:%.*]], i1 false
+; CHECK-NEXT:    [[SEL2:%.*]] = select i1 [[CMP]], i1 true, i1 [[SEL1]]
+; CHECK-NEXT:    ret i1 [[SEL2]]
+;
+  %trunc = trunc i8 %x to i1
+  %cmp = icmp eq i8 %x, 0
+  %sel1 = select i1 %trunc, i1 %c, i1 false
+  %sel2 = select i1 %cmp, i1 true, i1 %sel1
+  ret i1 %sel2
+}

Copy link
Member

@dtcxzyw dtcxzyw left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you!

Can you have a look at the following more canonical pattern?

Alive2: https://alive2.llvm.org/ce/z/SgMDwv

define i1 @src(i8 %x, i1 %c) {
  %trunc = trunc nuw i8 %x to i1
  %cmp = icmp eq i8 %x, 0
  %sel11 = and i1 %cmp, %c ; <- select i1 %cmp, i1 %c, i1 false
  %sel2 = select i1 %trunc, i1 true, i1 %sel11
  ret i1 %sel2
}

define i1 @tgt(i8 %x, i1 %c) {
  %trunc = trunc nuw i8 %x to i1
  %sel2 = select i1 %trunc, i1 true, i1 %c
  ret i1 %sel2
}

@andjo403 andjo403 merged commit 58ead2c into llvm:main May 27, 2025
15 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented May 27, 2025

LLVM Buildbot has detected a new failure on builder sanitizer-x86_64-linux running on sanitizer-buildbot2 while building llvm at step 2 "annotate".

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

Here is the relevant piece of the build log for the reference
Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure)
...
llvm-lit: /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:248: warning: COMPILER_RT_TEST_STANDALONE_BUILD_LIBS=ON, but this test suite does not support testing the just-built runtime libraries when the test compiler is configured to use different runtime libraries. Either modify this test suite to support this test configuration, or set COMPILER_RT_TEST_STANDALONE_BUILD_LIBS=OFF to test the runtime libraries included in the compiler instead.
llvm-lit: /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:259: note: Testing using libraries in "/home/b/sanitizer-x86_64-linux/build/build_default/./lib/../lib/clang/21/lib/i386-unknown-linux-gnu"
llvm-lit: /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:237: warning: Compiler lib dir != compiler-rt lib dir
Compiler libdir:     "/home/b/sanitizer-x86_64-linux/build/build_default/lib/clang/21/lib/i386-unknown-linux-gnu"
compiler-rt libdir:  "/home/b/sanitizer-x86_64-linux/build/build_default/lib/clang/21/lib/x86_64-unknown-linux-gnu"
llvm-lit: /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:248: warning: COMPILER_RT_TEST_STANDALONE_BUILD_LIBS=ON, but this test suite does not support testing the just-built runtime libraries when the test compiler is configured to use different runtime libraries. Either modify this test suite to support this test configuration, or set COMPILER_RT_TEST_STANDALONE_BUILD_LIBS=OFF to test the runtime libraries included in the compiler instead.
llvm-lit: /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:259: note: Testing using libraries in "/home/b/sanitizer-x86_64-linux/build/build_default/./lib/../lib/clang/21/lib/x86_64-unknown-linux-gnu"
llvm-lit: /home/b/sanitizer-x86_64-linux/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 4959 of 10831 tests, 88 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
FAIL: ThreadSanitizer-x86_64 :: deadlock_detector_stress_test.cpp (4937 of 4959)
******************** TEST 'ThreadSanitizer-x86_64 :: deadlock_detector_stress_test.cpp' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
/home/b/sanitizer-x86_64-linux/build/build_default/./bin/clang  --driver-mode=g++ -fsanitize=thread -Wall  -m64  -msse4.2   -gline-tables-only -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/../ -std=c++11 -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/../ -nostdinc++ -I/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_x86_64/include/c++/v1 /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deadlock_detector_stress_test.cpp -o /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/X86_64Config/Output/deadlock_detector_stress_test.cpp.tmp -DLockType=PthreadMutex # RUN: at line 1
+ /home/b/sanitizer-x86_64-linux/build/build_default/./bin/clang --driver-mode=g++ -fsanitize=thread -Wall -m64 -msse4.2 -gline-tables-only -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/../ -std=c++11 -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/../ -nostdinc++ -I/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_x86_64/include/c++/v1 /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deadlock_detector_stress_test.cpp -o /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/X86_64Config/Output/deadlock_detector_stress_test.cpp.tmp -DLockType=PthreadMutex
/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deflake.bash 10  /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/X86_64Config/Output/deadlock_detector_stress_test.cpp.tmp | FileCheck /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deadlock_detector_stress_test.cpp --check-prefix=CHECK --check-prefix=CHECK-NOT-SECOND # RUN: at line 2
+ FileCheck /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deadlock_detector_stress_test.cpp --check-prefix=CHECK --check-prefix=CHECK-NOT-SECOND
+ /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deflake.bash 10 /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/X86_64Config/Output/deadlock_detector_stress_test.cpp.tmp
env TSAN_OPTIONS=atexit_sleep_ms=0:second_deadlock_stack=1 /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deflake.bash 10  /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/X86_64Config/Output/deadlock_detector_stress_test.cpp.tmp | FileCheck /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deadlock_detector_stress_test.cpp --check-prefix=CHECK --check-prefix=CHECK-SECOND # RUN: at line 3
+ FileCheck /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deadlock_detector_stress_test.cpp --check-prefix=CHECK --check-prefix=CHECK-SECOND
+ env TSAN_OPTIONS=atexit_sleep_ms=0:second_deadlock_stack=1 /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deflake.bash 10 /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/X86_64Config/Output/deadlock_detector_stress_test.cpp.tmp
/home/b/sanitizer-x86_64-linux/build/build_default/./bin/clang  --driver-mode=g++ -fsanitize=thread -Wall  -m64  -msse4.2   -gline-tables-only -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/../ -std=c++11 -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/../ -nostdinc++ -I/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_x86_64/include/c++/v1 /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deadlock_detector_stress_test.cpp -o /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/X86_64Config/Output/deadlock_detector_stress_test.cpp.tmp -DLockType=PthreadSpinLock # RUN: at line 4
+ /home/b/sanitizer-x86_64-linux/build/build_default/./bin/clang --driver-mode=g++ -fsanitize=thread -Wall -m64 -msse4.2 -gline-tables-only -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/../ -std=c++11 -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/../ -nostdinc++ -I/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_x86_64/include/c++/v1 /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deadlock_detector_stress_test.cpp -o /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/X86_64Config/Output/deadlock_detector_stress_test.cpp.tmp -DLockType=PthreadSpinLock
/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deflake.bash 10  /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/X86_64Config/Output/deadlock_detector_stress_test.cpp.tmp | FileCheck /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deadlock_detector_stress_test.cpp # RUN: at line 5
+ /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deflake.bash 10 /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/X86_64Config/Output/deadlock_detector_stress_test.cpp.tmp
+ FileCheck /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deadlock_detector_stress_test.cpp
/home/b/sanitizer-x86_64-linux/build/build_default/./bin/clang  --driver-mode=g++ -fsanitize=thread -Wall  -m64  -msse4.2   -gline-tables-only -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/../ -std=c++11 -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/../ -nostdinc++ -I/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_x86_64/include/c++/v1 /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deadlock_detector_stress_test.cpp -o /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/X86_64Config/Output/deadlock_detector_stress_test.cpp.tmp -DLockType=PthreadRWLock # RUN: at line 6
+ /home/b/sanitizer-x86_64-linux/build/build_default/./bin/clang --driver-mode=g++ -fsanitize=thread -Wall -m64 -msse4.2 -gline-tables-only -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/../ -std=c++11 -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/../ -nostdinc++ -I/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_x86_64/include/c++/v1 /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deadlock_detector_stress_test.cpp -o /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/X86_64Config/Output/deadlock_detector_stress_test.cpp.tmp -DLockType=PthreadRWLock
/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deflake.bash 10  /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/X86_64Config/Output/deadlock_detector_stress_test.cpp.tmp | FileCheck /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deadlock_detector_stress_test.cpp --check-prefix=CHECK --check-prefix=CHECK-RD # RUN: at line 7
+ FileCheck /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deadlock_detector_stress_test.cpp --check-prefix=CHECK --check-prefix=CHECK-RD
+ /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deflake.bash 10 /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/X86_64Config/Output/deadlock_detector_stress_test.cpp.tmp
/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deadlock_detector_stress_test.cpp:389:15: error: CHECK-RD: expected string not found in input
 // CHECK-RD: Starting Test13
              ^
<stdin>:227:16: note: scanning from here
Starting Test12: 4 threads read lock/unlock 4 shared mutexes, one under another
               ^
<stdin>:231:64: note: possible intended match here
 #2 void __tsan::TraceEvent<__tsan::EventUnlock>(__tsan::ThreadState*, __tsan::EventUnlock) /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/tsan/rtl/tsan_rtl.h (deadlock_detector_stress_test.cpp.tmp+0x105fe3)
                                                               ^

Input file: <stdin>
Check file: /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deadlock_detector_stress_test.cpp

-dump-input=help explains the following input dump.

Step 11 (test compiler-rt debug) failure: test compiler-rt debug (failure)
...
llvm-lit: /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:248: warning: COMPILER_RT_TEST_STANDALONE_BUILD_LIBS=ON, but this test suite does not support testing the just-built runtime libraries when the test compiler is configured to use different runtime libraries. Either modify this test suite to support this test configuration, or set COMPILER_RT_TEST_STANDALONE_BUILD_LIBS=OFF to test the runtime libraries included in the compiler instead.
llvm-lit: /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:259: note: Testing using libraries in "/home/b/sanitizer-x86_64-linux/build/build_default/./lib/../lib/clang/21/lib/i386-unknown-linux-gnu"
llvm-lit: /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:237: warning: Compiler lib dir != compiler-rt lib dir
Compiler libdir:     "/home/b/sanitizer-x86_64-linux/build/build_default/lib/clang/21/lib/i386-unknown-linux-gnu"
compiler-rt libdir:  "/home/b/sanitizer-x86_64-linux/build/build_default/lib/clang/21/lib/x86_64-unknown-linux-gnu"
llvm-lit: /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:248: warning: COMPILER_RT_TEST_STANDALONE_BUILD_LIBS=ON, but this test suite does not support testing the just-built runtime libraries when the test compiler is configured to use different runtime libraries. Either modify this test suite to support this test configuration, or set COMPILER_RT_TEST_STANDALONE_BUILD_LIBS=OFF to test the runtime libraries included in the compiler instead.
llvm-lit: /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:259: note: Testing using libraries in "/home/b/sanitizer-x86_64-linux/build/build_default/./lib/../lib/clang/21/lib/x86_64-unknown-linux-gnu"
llvm-lit: /home/b/sanitizer-x86_64-linux/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 4959 of 10831 tests, 88 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
FAIL: ThreadSanitizer-x86_64 :: deadlock_detector_stress_test.cpp (4937 of 4959)
******************** TEST 'ThreadSanitizer-x86_64 :: deadlock_detector_stress_test.cpp' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
/home/b/sanitizer-x86_64-linux/build/build_default/./bin/clang  --driver-mode=g++ -fsanitize=thread -Wall  -m64  -msse4.2   -gline-tables-only -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/../ -std=c++11 -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/../ -nostdinc++ -I/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_x86_64/include/c++/v1 /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deadlock_detector_stress_test.cpp -o /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/X86_64Config/Output/deadlock_detector_stress_test.cpp.tmp -DLockType=PthreadMutex # RUN: at line 1
+ /home/b/sanitizer-x86_64-linux/build/build_default/./bin/clang --driver-mode=g++ -fsanitize=thread -Wall -m64 -msse4.2 -gline-tables-only -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/../ -std=c++11 -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/../ -nostdinc++ -I/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_x86_64/include/c++/v1 /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deadlock_detector_stress_test.cpp -o /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/X86_64Config/Output/deadlock_detector_stress_test.cpp.tmp -DLockType=PthreadMutex
/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deflake.bash 10  /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/X86_64Config/Output/deadlock_detector_stress_test.cpp.tmp | FileCheck /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deadlock_detector_stress_test.cpp --check-prefix=CHECK --check-prefix=CHECK-NOT-SECOND # RUN: at line 2
+ FileCheck /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deadlock_detector_stress_test.cpp --check-prefix=CHECK --check-prefix=CHECK-NOT-SECOND
+ /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deflake.bash 10 /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/X86_64Config/Output/deadlock_detector_stress_test.cpp.tmp
env TSAN_OPTIONS=atexit_sleep_ms=0:second_deadlock_stack=1 /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deflake.bash 10  /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/X86_64Config/Output/deadlock_detector_stress_test.cpp.tmp | FileCheck /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deadlock_detector_stress_test.cpp --check-prefix=CHECK --check-prefix=CHECK-SECOND # RUN: at line 3
+ FileCheck /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deadlock_detector_stress_test.cpp --check-prefix=CHECK --check-prefix=CHECK-SECOND
+ env TSAN_OPTIONS=atexit_sleep_ms=0:second_deadlock_stack=1 /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deflake.bash 10 /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/X86_64Config/Output/deadlock_detector_stress_test.cpp.tmp
/home/b/sanitizer-x86_64-linux/build/build_default/./bin/clang  --driver-mode=g++ -fsanitize=thread -Wall  -m64  -msse4.2   -gline-tables-only -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/../ -std=c++11 -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/../ -nostdinc++ -I/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_x86_64/include/c++/v1 /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deadlock_detector_stress_test.cpp -o /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/X86_64Config/Output/deadlock_detector_stress_test.cpp.tmp -DLockType=PthreadSpinLock # RUN: at line 4
+ /home/b/sanitizer-x86_64-linux/build/build_default/./bin/clang --driver-mode=g++ -fsanitize=thread -Wall -m64 -msse4.2 -gline-tables-only -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/../ -std=c++11 -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/../ -nostdinc++ -I/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_x86_64/include/c++/v1 /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deadlock_detector_stress_test.cpp -o /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/X86_64Config/Output/deadlock_detector_stress_test.cpp.tmp -DLockType=PthreadSpinLock
/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deflake.bash 10  /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/X86_64Config/Output/deadlock_detector_stress_test.cpp.tmp | FileCheck /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deadlock_detector_stress_test.cpp # RUN: at line 5
+ /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deflake.bash 10 /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/X86_64Config/Output/deadlock_detector_stress_test.cpp.tmp
+ FileCheck /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deadlock_detector_stress_test.cpp
/home/b/sanitizer-x86_64-linux/build/build_default/./bin/clang  --driver-mode=g++ -fsanitize=thread -Wall  -m64  -msse4.2   -gline-tables-only -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/../ -std=c++11 -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/../ -nostdinc++ -I/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_x86_64/include/c++/v1 /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deadlock_detector_stress_test.cpp -o /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/X86_64Config/Output/deadlock_detector_stress_test.cpp.tmp -DLockType=PthreadRWLock # RUN: at line 6
+ /home/b/sanitizer-x86_64-linux/build/build_default/./bin/clang --driver-mode=g++ -fsanitize=thread -Wall -m64 -msse4.2 -gline-tables-only -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/../ -std=c++11 -I/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/../ -nostdinc++ -I/home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/lib/tsan/libcxx_tsan_x86_64/include/c++/v1 /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deadlock_detector_stress_test.cpp -o /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/X86_64Config/Output/deadlock_detector_stress_test.cpp.tmp -DLockType=PthreadRWLock
/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deflake.bash 10  /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/X86_64Config/Output/deadlock_detector_stress_test.cpp.tmp | FileCheck /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deadlock_detector_stress_test.cpp --check-prefix=CHECK --check-prefix=CHECK-RD # RUN: at line 7
+ FileCheck /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deadlock_detector_stress_test.cpp --check-prefix=CHECK --check-prefix=CHECK-RD
+ /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deflake.bash 10 /home/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/tsan/X86_64Config/Output/deadlock_detector_stress_test.cpp.tmp
/home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deadlock_detector_stress_test.cpp:389:15: error: CHECK-RD: expected string not found in input
 // CHECK-RD: Starting Test13
              ^
<stdin>:227:16: note: scanning from here
Starting Test12: 4 threads read lock/unlock 4 shared mutexes, one under another
               ^
<stdin>:231:64: note: possible intended match here
 #2 void __tsan::TraceEvent<__tsan::EventUnlock>(__tsan::ThreadState*, __tsan::EventUnlock) /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/tsan/rtl/tsan_rtl.h (deadlock_detector_stress_test.cpp.tmp+0x105fe3)
                                                               ^

Input file: <stdin>
Check file: /home/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/tsan/deadlock_detector_stress_test.cpp

-dump-input=help explains the following input dump.


@andjo403
Copy link
Contributor Author

LGTM. Thank you!

Can you have a look at the following more canonical pattern?

Alive2: https://alive2.llvm.org/ce/z/SgMDwv

define i1 @src(i8 %x, i1 %c) {
  %trunc = trunc nuw i8 %x to i1
  %cmp = icmp eq i8 %x, 0
  %sel11 = and i1 %cmp, %c ; <- select i1 %cmp, i1 %c, i1 false
  %sel2 = select i1 %trunc, i1 true, i1 %sel11
  ret i1 %sel2
}

define i1 @tgt(i8 %x, i1 %c) {
  %trunc = trunc nuw i8 %x to i1
  %sel2 = select i1 %trunc, i1 true, i1 %c
  ret i1 %sel2
}

@dtcxzyw hade a look at this pattern and created a change for it but there is no improvements in llvm-opt-benchmark so it seems like it is not common.

@andjo403 andjo403 deleted the impliedFromTruncCond branch May 27, 2025 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llvm:analysis Includes value tracking, cost tables and constant folding llvm:instcombine Covers the InstCombine, InstSimplify and AggressiveInstCombine passes llvm:transforms

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants