← Back to Pull requests

[InstCombine] Generalize existing pattern from "abs(val) != 0 -> val != 0" to "abs(val) == 0 -> val == 0" #233763

Merged
Misasasa merged 3 files (48 lines) on Oct 28, 2026 11:20 UTC
View on GitHub
Misasasa Misasasa commented on Oct 20, 2026 09:34 UTC
Author

Generalize fold of (c ? x : -x) != 0 to x != 0 by moving the pattern to stripNullTest() and thus also supporting == predicates and other patterns supported by that helper.

The missed pattern is noticed in Google Abseil's demangler (https://github.com/abseil/abseil-cpp/blob/master/absl/debugging/internal/demangle.cc).

Proof: https://alive2.llvm.org/ce/z/7WQeXT

Fixes #233753

Assisted-by: Qwen3.7-Plus, which helps me locate the existing pattern instead of opening a new pattern.

Diff: 48 lines (+32 / -16) across 3 files Reviewer: nikic Review duration: 11625m
All Vouch review confidence checks passed
Residual risk 0.03 = Change Risk (0.29) × (1 − Review Confidence (0.90)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.29 · 48 lines diff across 3 files
0.29
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.88 · 5 substantive comment(s)
0.88
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
89%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.233
Real PR Conversation Timeline
20 items
github-actions[bot] github-actions[bot] commented on Oct 20, 2026 09:34 UTC
Bot

<!--LLVM NEW CONTRIBUTOR COMMENT-->

Hello @Misasasa :wave:

Thank you for submitting a Pull Request (PR) to the LLVM Project. Since this is your first PR, here are a few useful links covering our main contribution policies and review practices.

All contributions to LLVM must follow our LLVM AI Tool Use Policy. In particular, if you used AI while working on this PR, remember to add a note to the PR description.
The LLVM Code-Review Policy and Practices document contains practical information about the PR process, including how patches are reviewed and accepted, and who can review a PR.
Our LLVM Developer Policy describes our expectations for code quality, commit summaries and contains notes on our CI system.
The InstCombine Contributor Guide lays out a series of rules that contributions to InstCombine (and other middle-end components) should follow.

Please reply to this message to confirm that you have read these policies, especially the LLVM AI Tool Use Policy, and that any AI tool usage has been noted in the PR description.

---

Frequently asked questions

How do I add reviewers?

This PR will be automatically labeled, and the relevant teams will be notified. For some parts of the project, reviewers may also be added automatically.

You can also add reviewers manually using the Reviewers section on this page. If you cannot use that section, it is probably because you do not have write permissions for the repository. In that case, you can request a review by tagging reviewers in a comment using @ followed by their GitHub username.

What if there are no comments?

If you have not received any comments on your PR after a week, you can request a review by pinging the PR with a comment such as “Ping”. The common courtesy ping rate is once a week. Please remember that you are asking for volunteer time from other developers.

Are any special GitHub settings required to contribute to LLVM?

We only require contributors to have a public email address associated with their GitHub commits, see this section of LLVM Developer Policy for details.

---

If you have questions, feel free to leave a comment on this PR, or ask on LLVM Discord or LLVM Discourse.

Thank you,
The LLVM Community

llvmorg-github-actions[bot] llvmorg-github-actions[bot] commented on Oct 20, 2026 09:35 UTC
Bot

<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-analysis

@llvm/pr-subscribers-llvm-transforms

Author: Archmushroom (Misasasa)

<details>
<summary>Changes</summary>

Summary

Fixes #<!-- -->233753

There has been an available fold:

define i1 @<!-- -->src(i32 %x, i1 %cond) {
  %negx = sub i32 0, %x
  %somex = select i1 %cond, i32 %negx, i32 %x
  %ret = icmp ne i32 %somex, 0
  ret i1 %ret
}

define i1 @<!-- -->tgt(i32 %x, i1 %cond) {
  %ret = icmp ne i32 %x, 0
  ret i1 %ret
}

Likewise, this fold (ne replaced with eq) is also correct but missed:

define i1 @<!-- -->src(i32 %x, i1 %cond) {
  %negx = sub i32 0, %x
  %somex = select i1 %cond, i32 %negx, i32 %x
  %ret = icmp eq i32 %somex, 0
  ret i1 %ret
}

define i1 @<!-- -->tgt(i32 %x, i1 %cond) {
  %ret = icmp eq i32 %x, 0
  ret i1 %ret
}

https://alive2.llvm.org/ce/z/7WQeXT

This PR generalizes the corresponding pattern for both cases.

Motivation

The missed pattern is noticed in Google Abseil's demangler.

Assisted-by

Qwen3.7-Plus, which helps me locate the existing pattern instead of opening a new pattern.

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

2 Files Affected:

  • (modified) llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp (+3-3)

  • (modified) llvm/test/Transforms/InstCombine/icmp.ll (+30-4)
  • ``````

    diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
    index 8893744821f7e6..23648ca1a1a65c 100644
    --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
    +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
    @@ -8013,9 +8013,9 @@ Instruction *InstCombinerImpl::visitICmpInst(ICmpInst &I) {
       if (Value *V = simplifyICmpInst(I.getCmpPredicate(), Op0, Op1, Q))
         return replaceInstUsesWith(I, V);
     
    -  // Comparing -val or val with non-zero is the same as just comparing val
    -  // ie, abs(val) != 0 -> val != 0
    -  if (I.getPredicate() == ICmpInst::ICMP_NE && match(Op1, m_Zero())) {
    +  // Comparing -val or val with zero is the same as just comparing val
    +  // ie, abs(val) == 0 -> val == 0, abs(val) != 0 -> val != 0
    +  if (ICmpInst::isEquality(I.getPredicate()) && match(Op1, m_Zero())) {
         Value *Cond, *SelectTrue, *SelectFalse;
         if (match(Op0, m_Select(m_Value(Cond), m_Value(SelectTrue),
                                 m_Value(SelectFalse)))) {
    diff --git a/llvm/test/Transforms/InstCombine/icmp.ll b/llvm/test/Transforms/InstCombine/icmp.ll
    index c7bae58a0b1974..c49b2d6c7fc3b3 100644
    --- a/llvm/test/Transforms/InstCombine/icmp.ll
    +++ b/llvm/test/Transforms/InstCombine/icmp.ll
    @@ -1279,8 +1279,8 @@ define i1 @test57(i32 %a) {
     }
     
     ; rdar://problem/10482509
    -define zeroext i1 @cmpabs1(i64 %val) {
    -; CHECK-LABEL: define zeroext i1 @cmpabs1(
    +define zeroext i1 @cmpabs_ne1(i64 %val) {
    +; CHECK-LABEL: define zeroext i1 @cmpabs_ne1(
     ; CHECK-SAME: i64 [[VAL:%.*]]) {
     ; CHECK-NEXT:    [[TOBOOL:%.*]] = icmp ne i64 [[VAL]], 0
     ; CHECK-NEXT:    ret i1 [[TOBOOL]]
    @@ -1292,8 +1292,8 @@ define zeroext i1 @cmpabs1(i64 %val) {
       ret i1 %tobool
     }
     
    -define zeroext i1 @cmpabs2(i64 %val) {
    -; CHECK-LABEL: define zeroext i1 @cmpabs2(
    +define zeroext i1 @cmpabs_ne2(i64 %val) {
    +; CHECK-LABEL: define zeroext i1 @cmpabs_ne2(
     ; CHECK-SAME: i64 [[VAL:%.*]]) {
     ; CHECK-NEXT:    [[TOBOOL:%.*]] = icmp ne i64 [[VAL]], 0
     ; CHECK-NEXT:    ret i1 [[TOBOOL]]
    @@ -1305,6 +1305,32 @@ define zeroext i1 @cmpabs2(i64 %val) {
       ret i1 %tobool
     }
     
    +define zeroext i1 @cmpabs_eq1(i64 %val) {
    +; CHECK-LABEL: define zeroext i1 @cmpabs_eq1(
    +; CHECK-SAME: i64 [[VAL:%.*]]) {
    +; CHECK-NEXT:    [[TOBOOL:%.*]] = icmp eq i64 [[VAL]], 0
    +; CHECK-NEXT:    ret i1 [[TOBOOL]]
    +;
    +  %sub = sub nsw i64 0, %val
    +  %cmp = icmp slt i64 %val, 0
    +  %sub.val = select i1 %cmp, i64 %sub, i64 %val
    +  %tobool = icmp eq i64 %sub.val, 0
    +  ret i1 %tobool
    +}
    +
    +define zeroext i1 @cmpabs_eq2(i64 %val) {
    +; CHECK-LABEL: define zeroext i1 @cmpabs_eq2(
    +; CHECK-SAME: i64 [[VAL:%.*]]) {
    +; CHECK-NEXT:    [[TOBOOL:%.*]] = icmp eq i64 [[VAL]], 0
    +; CHECK-NEXT:    ret i1 [[TOBOOL]]
    +;
    +  %sub = sub nsw i64 0, %val
    +  %cmp = icmp slt i64 %val, 0
    +  %sub.val = select i1 %cmp, i64 %val, i64 %sub
    +  %tobool = icmp eq i64 %sub.val, 0
    +  ret i1 %tobool
    +}
    +
     define i1 @abs_intrin_eq_zero(i8 %x) {
     ; CHECK-LABEL: define i1 @abs_intrin_eq_zero(
     ; CHECK-SAME: i8 [[X:%.*]]) {
    
    
    ``````

    </details>

    dtcxzyw dtcxzyw commented on code on Oct 20, 2026 11:41 UTC
    Code Review
    llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:1
    @@ -8013,9 +8013,9 @@ Instruction *InstCombinerImpl::visitICmpInst(ICmpInst &I) {
       if (Value *V = simplifyICmpInst(I.getCmpPredicate(), Op0, Op1, Q))
         return replaceInstUsesWith(I, V);
     
    -  // Comparing -val or val with non-zero is the same as just comparing val
    -  // ie, abs(val) != 0 -> val != 0
    -  if (I.getPredicate() == ICmpInst::ICMP_NE && match(Op1, m_Zero())) {
    +  // Comparing -val or val with zero is the same as just comparing val
    +  // ie, abs(val) == 0 -> val == 0, abs(val) != 0 -> val != 0

    Can you please move this pattern into stripNullTest?

    Misasasa Misasasa commented on code on Oct 21, 2026 03:57 UTC
    Code Review
    llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:1
    @@ -8013,9 +8013,9 @@ Instruction *InstCombinerImpl::visitICmpInst(ICmpInst &I) {
       if (Value *V = simplifyICmpInst(I.getCmpPredicate(), Op0, Op1, Q))
         return replaceInstUsesWith(I, V);
     
    -  // Comparing -val or val with non-zero is the same as just comparing val
    -  // ie, abs(val) != 0 -> val != 0
    -  if (I.getPredicate() == ICmpInst::ICMP_NE && match(Op1, m_Zero())) {
    +  // Comparing -val or val with zero is the same as just comparing val
    +  // ie, abs(val) == 0 -> val == 0, abs(val) != 0 -> val != 0

    Done. But one thing I'm not sure about.

    Previously, dyn_castNegVal (unfortunately unavailable in ValueTracking)
    matches both variables and constants, so I refactor it into two blocks:
    https://github.com/Misasasa/llvm-project/blob/f362b329b57b151816dc3cec3f7ecf2778567e0d/llvm/lib/Analysis/ValueTracking.cpp#L11125-L11130
    and
    https://github.com/Misasasa/llvm-project/blob/f362b329b57b151816dc3cec3f7ecf2778567e0d/llvm/lib/Analysis/ValueTracking.cpp#L11131-L11140

    However, I find that even without the constant block, related optimizations still work, like:

  • https://alive2.llvm.org/ce/z/zBytGQ

  • https://alive2.llvm.org/ce/z/ARXASH

  • https://alive2.llvm.org/ce/z/1Wkg8S
  • This is why I'm not sure whether the constant block is necessary.

    dtcxzyw dtcxzyw commented on code on Oct 21, 2026 15:03 UTC
    Code Review
    llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:1
    @@ -8013,9 +8013,9 @@ Instruction *InstCombinerImpl::visitICmpInst(ICmpInst &I) {
       if (Value *V = simplifyICmpInst(I.getCmpPredicate(), Op0, Op1, Q))
         return replaceInstUsesWith(I, V);
     
    -  // Comparing -val or val with non-zero is the same as just comparing val
    -  // ie, abs(val) != 0 -> val != 0
    -  if (I.getPredicate() == ICmpInst::ICMP_NE && match(Op1, m_Zero())) {
    +  // Comparing -val or val with zero is the same as just comparing val
    +  // ie, abs(val) == 0 -> val == 0, abs(val) != 0 -> val != 0

    Constant path is unnecessary. InstSimplify can fold the comparison into true/false.

    dtcxzyw dtcxzyw commented on code on Oct 21, 2026 15:04 UTC
    Code Review
    llvm/lib/Analysis/ValueTracking.cpp:1
    @@ -11117,6 +11117,29 @@ const Value *llvm::stripNullTest(const Value *V) {
             return X;
         }
       }
    +
    +  // select(cond, X, -X) or select(cond, -X, X)
    +  if (const auto *SI = dyn_cast<SelectInst>(V)) {

    match(V, m_c_Select(m_Value(X), m_Neg(m_Deferred(X)))).

    Misasasa Misasasa commented on code on Oct 22, 2026 03:17 UTC
    Code Review
    llvm/lib/Analysis/ValueTracking.cpp:1
    @@ -11117,6 +11117,29 @@ const Value *llvm::stripNullTest(const Value *V) {
             return X;
         }
       }
    +
    +  // select(cond, X, -X) or select(cond, -X, X)
    +  if (const auto *SI = dyn_cast<SelectInst>(V)) {

    Done!

    Misasasa Misasasa commented on Oct 23, 2026 08:59 UTC
    Author

    This is a weild failure. My changes should not affect tests like lld :: COFF/pdb-thinlto.ll. Could anyone please help me with these checks? @dtcxzyw @RKSimon

    RKSimon RKSimon commented on Oct 23, 2026 09:38 UTC
    Contributor

    This is a weild failure. My changes should not affect tests like lld :: COFF/pdb-thinlto.ll. Could anyone please help me with these checks? @dtcxzyw @RKSimon

    Its most likely a flakey test - trying merging against latest to kick off a fresh CI build

    nikic nikic commented on code on Oct 23, 2026 15:09 UTC
    Code Review
    llvm/test/Transforms/InstCombine/icmp.ll:1
    @@ -1305,6 +1305,32 @@ define zeroext i1 @cmpabs2(i64 %val) {
       ret i1 %tobool
     }
     
    +define zeroext i1 @cmpabs_eq1(i64 %val) {
    +; CHECK-LABEL: define zeroext i1 @cmpabs_eq1(
    +; CHECK-SAME: i64 [[VAL:%.*]]) {
    +; CHECK-NEXT:    [[TOBOOL:%.*]] = icmp eq i64 [[VAL]], 0
    +; CHECK-NEXT:    ret i1 [[TOBOOL]]
    +;
    +  %sub = sub nsw i64 0, %val
    +  %cmp = icmp slt i64 %val, 0
    +  %sub.val = select i1 %cmp, i64 %sub, i64 %val
    +  %tobool = icmp eq i64 %sub.val, 0
    +  ret i1 %tobool
    +}
    +
    +define zeroext i1 @cmpabs_eq2(i64 %val) {
    +; CHECK-LABEL: define zeroext i1 @cmpabs_eq2(
    +; CHECK-SAME: i64 [[VAL:%.*]]) {
    +; CHECK-NEXT:    [[TOBOOL:%.*]] = icmp eq i64 [[VAL]], 0
    +; CHECK-NEXT:    ret i1 [[TOBOOL]]
    +;
    +  %sub = sub nsw i64 0, %val
    +  %cmp = icmp slt i64 %val, 0
    +  %sub.val = select i1 %cmp, i64 %val, i64 %sub
    +  %tobool = icmp eq i64 %sub.val, 0
    +  ret i1 %tobool
    +}
    nikic nikic commented on code on Oct 23, 2026 19:37 UTC
    Code Review
    llvm/test/Transforms/InstCombine/icmp.ll:1
    @@ -1305,6 +1305,32 @@ define zeroext i1 @cmpabs2(i64 %val) {
       ret i1 %tobool
     }
     
    +define zeroext i1 @cmpabs_eq1(i64 %val) {
    +; CHECK-LABEL: define zeroext i1 @cmpabs_eq1(
    +; CHECK-SAME: i64 [[VAL:%.*]]) {
    +; CHECK-NEXT:    [[TOBOOL:%.*]] = icmp eq i64 [[VAL]], 0
    +; CHECK-NEXT:    ret i1 [[TOBOOL]]
    +;
    +  %sub = sub nsw i64 0, %val
    +  %cmp = icmp slt i64 %val, 0
    +  %sub.val = select i1 %cmp, i64 %sub, i64 %val
    +  %tobool = icmp eq i64 %sub.val, 0
    +  ret i1 %tobool
    +}
    +
    +define zeroext i1 @cmpabs_eq2(i64 %val) {
    +; CHECK-LABEL: define zeroext i1 @cmpabs_eq2(
    +; CHECK-SAME: i64 [[VAL:%.*]]) {
    +; CHECK-NEXT:    [[TOBOOL:%.*]] = icmp eq i64 [[VAL]], 0
    +; CHECK-NEXT:    ret i1 [[TOBOOL]]
    +;
    +  %sub = sub nsw i64 0, %val
    +  %cmp = icmp slt i64 %val, 0
    +  %sub.val = select i1 %cmp, i64 %val, i64 %sub
    +  %tobool = icmp eq i64 %sub.val, 0
    +  ret i1 %tobool
    +}

    Presumably you just need to replace the condition with an i1 %c argument or similar, so the select doesn't fold to abs.

    Misasasa Misasasa commented on code on Oct 26, 2026 07:02 UTC
    Code Review
    llvm/test/Transforms/InstCombine/icmp.ll:1
    @@ -1305,6 +1305,32 @@ define zeroext i1 @cmpabs2(i64 %val) {
       ret i1 %tobool
     }
     
    +define zeroext i1 @cmpabs_eq1(i64 %val) {
    +; CHECK-LABEL: define zeroext i1 @cmpabs_eq1(
    +; CHECK-SAME: i64 [[VAL:%.*]]) {
    +; CHECK-NEXT:    [[TOBOOL:%.*]] = icmp eq i64 [[VAL]], 0
    +; CHECK-NEXT:    ret i1 [[TOBOOL]]
    +;
    +  %sub = sub nsw i64 0, %val
    +  %cmp = icmp slt i64 %val, 0
    +  %sub.val = select i1 %cmp, i64 %sub, i64 %val
    +  %tobool = icmp eq i64 %sub.val, 0
    +  ret i1 %tobool
    +}
    +
    +define zeroext i1 @cmpabs_eq2(i64 %val) {
    +; CHECK-LABEL: define zeroext i1 @cmpabs_eq2(
    +; CHECK-SAME: i64 [[VAL:%.*]]) {
    +; CHECK-NEXT:    [[TOBOOL:%.*]] = icmp eq i64 [[VAL]], 0
    +; CHECK-NEXT:    ret i1 [[TOBOOL]]
    +;
    +  %sub = sub nsw i64 0, %val
    +  %cmp = icmp slt i64 %val, 0
    +  %sub.val = select i1 %cmp, i64 %val, i64 %sub
    +  %tobool = icmp eq i64 %sub.val, 0
    +  ret i1 %tobool
    +}

    Thanks for your suggestion! Now tests cannot fold without changes: https://llvm.godbolt.org/z/WP1W7Khvq

    nikic nikic commented on code on Oct 26, 2026 07:57 UTC
    Code Review
    llvm/test/Transforms/InstCombine/icmp.ll:1
    @@ -1305,6 +1305,30 @@ define zeroext i1 @cmpabs2(i64 %val) {
       ret i1 %tobool
     }
     
    +define zeroext i1 @cmp_posorneg_eq1(i64 %val, i1 %cond) {
    +; CHECK-LABEL: define zeroext i1 @cmp_posorneg_eq1(
    +; CHECK-SAME: i64 [[VAL:%.*]], i1 [[COND:%.*]]) {
    +; CHECK-NEXT:    [[TOBOOL:%.*]] = icmp eq i64 [[VAL]], 0
    +; CHECK-NEXT:    ret i1 [[TOBOOL]]
    +;
    +  %sub = sub nsw i64 0, %val

      %sub = sub i64 0, %val
    

    These nsw's should not be necessary for the fold.

    nikic nikic approved these changes on Oct 26, 2026 07:57 UTC
    Approved Reviewer

    LGTM with one nit.

    Misasasa Misasasa commented on code on Oct 27, 2026 01:54 UTC
    Code Review
    llvm/test/Transforms/InstCombine/icmp.ll:1
    @@ -1305,6 +1305,30 @@ define zeroext i1 @cmpabs2(i64 %val) {
       ret i1 %tobool
     }
     
    +define zeroext i1 @cmp_posorneg_eq1(i64 %val, i1 %cond) {
    +; CHECK-LABEL: define zeroext i1 @cmp_posorneg_eq1(
    +; CHECK-SAME: i64 [[VAL:%.*]], i1 [[COND:%.*]]) {
    +; CHECK-NEXT:    [[TOBOOL:%.*]] = icmp eq i64 [[VAL]], 0
    +; CHECK-NEXT:    ret i1 [[TOBOOL]]
    +;
    +  %sub = sub nsw i64 0, %val

    Thanks for your suggestion! I have removed nsw's in both test cases.

    nikic nikic approved these changes on Oct 27, 2026 08:31 UTC
    Approved Reviewer

    LGTM

    nikic nikic commented on Oct 27, 2026 08:35 UTC
    Contributor

    This commit will be authored by 45325799+Misasasa@users.noreply.github.com.

    Can you please disable the private email option in your GitHub settings? See https://llvm.org/docs/DeveloperPolicy.html#email-addresses.

    Misasasa Misasasa commented on Oct 28, 2026 10:21 UTC
    Author

    > This commit will be authored by [45325799+Misasasa@users.noreply.github.com](mailto:45325799+Misasasa@users.noreply.github.com).

    > Can you please disable the private email option in your GitHub settings? See https://llvm.org/docs/DeveloperPolicy.html#email-addresses.

    Done. Thanks for reminding me this!

    github-actions[bot] github-actions[bot] commented on Oct 28, 2026 11:20 UTC
    Bot

    <!--LLVM BUILDBOT INFORMATION COMMENT-->

    @Misasasa Congratulations on having your first Pull Request (PR) merged into the LLVM Project!

    Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR.

    Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues.

    How to do this, and the rest of the post-merge process, is covered in detail here.

    If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again.

    If you don't get any reports, no action is required from you. Your changes are working as expected, well done!

    Reviewers
    Assignees
    Misasasa Misasasa
    Labels
    risk: low confidence: 89.6% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 29.2% (LOW) · Higher = larger blast radius
    29.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 89.6% · Lower = rushed or shallow review
    89.6%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 3% · Safe to merge
    3%