Skip to content

Backport PR27137: Fix matchSelectPattern for bitwise-not of unsigned compares - #9080

Open
Natalie Chouinard (sudonatalie) wants to merge 6 commits into
microsoft:mainfrom
sudonatalie:backport-PR27137
Open

Natalie Chouinard (sudonatalie) wants to merge 6 commits into
microsoft:mainfrom
sudonatalie:backport-PR27137

Conversation

@sudonatalie

Copy link
Copy Markdown
Collaborator

This backports llvm/llvm-project@56df0ec (rL264996) which fixes PR27137. It corrects SPF_SMIN matching in matchSelectPattern where the previous code blindly assumed the predicate was ICMP_SGT, leading to incorrect MIN/MAX matching for other predicates.

…compares

This backports llvm/llvm-project@56df0ec (rL264996)
which fixes PR27137. It corrects SPF_SMIN matching in matchSelectPattern where
the previous code blindly assumed the predicate was ICMP_SGT, leading to
incorrect MIN/MAX matching for other predicates.
Copilot AI balanced review requested due to automatic review settings October 28, 2026 18:11
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The regression test is excluded from normal test discovery, so an active DXC test is needed to ensure CI catches a reversion of the matcher fix.

1 open issue
What changed in this PR

Backports LLVM’s PR27137 fix to DXC’s value-tracking analysis, correcting min/max recognition for selects involving bitwise-not comparisons.

Changes:

  • Restricts the affected pattern to signed comparisons and selects the correct minimum or maximum flavor.
  • Adds an LLVM IR regression case for the incorrect folding.
File Description
test/​Transforms/​InstCombine/​select.ll Adds the PR27137 regression case and expected optimized output.
lib/​Analysis/​ValueTracking.cpp Checks the comparison predicate before classifying the select as signed min/max.

Review effort: Balanced

Comment thread test/Transforms/InstCombine/select.ll Resolved
Copilot AI balanced review requested due to automatic review settings October 28, 2026 18:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The new regression test is in a disabled suite, leaving the miscompile fix without automated regression coverage in CI.

1 open issue
1 previously missed issue

In code that hasn't changed since last review

Low severity Document optimizer correctness fix in release notes

lib/​Analysis/​ValueTracking.cpp:3395

Please add a one-sentence bug-fix entry under ### Upcoming Release in docs/ReleaseNotes.md. This changes user-visible optimizer correctness by preventing incorrect min/max folding, and CONTRIBUTING.md calls for release notes for important compiler bug fixes; the current notes do not cover this change.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 28, 2026 18:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The regression test is in a disabled suite, leaving the miscompile fix without automated regression coverage until an equivalent test is added to the enabled DXC suite.

1 open issue

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 28, 2026 19:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the signed min/max recognition fix.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 28, 2026 19:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Human assessment is needed because the signed-only regression leaves the unsigned-predicate guard untested despite its role in preventing incorrect folds.

No open issues 🎉

Review effort: Balanced

@damyanp

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI balanced review requested due to automatic review settings October 30, 2026 16:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the targeted signed-minimum pattern fix and its regression coverage.

No open issues 🎉

Review effort: Balanced

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

3 participants