Skip to content

[vulkan] use logical comparison ops for boolean operands - #9670

Open
NekoAsakura wants to merge 4 commits into
halide:mainfrom
NekoAsakura:gh-9579-vulkan-bool-equality
Open

NekoAsakura wants to merge 4 commits into
halide:mainfrom
NekoAsakura:gh-9579-vulkan-bool-equality

Conversation

@NekoAsakura

Copy link
Copy Markdown

Fixes #9579.

ImageParam input(Int(32), 1, "input");
Expr a = input(x) > 0, b = input(x + 1) > 0;
Func output(name);
output(x) = not_equal ? cast<int32_t>(a != b) : select(a == b, 1, 0);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This is on purpose to avoid a simplifier rewrite.

To verify:

cmake --build build --target correctness_vulkan_bool_equality
HL_DEBUG_CODEGEN=1 build/test/correctness/correctness_vulkan_bool_equality 2>&1 >/dev/null | grep -A4 'bool_ne\[' | grep '0 < input'

With cast<int32_t>(a != b):

int32((0 < input[t306]) != (0 < input[t306 + 1]))
int32((0 < input[t307 + -32]) != (0 < input[t307 + -31]))

With select(a != b, 1, 0):

select((0 < input[t310]) == (0 < input[t310 + 1]), 0, 1)
select((0 < input[t311 + -32]) == (0 < input[t311 + -31]), 0, 1)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you elaborate? What's the simplifier rewrite in question? I'm slightly worried that a future change to the simplifier might make this test silently not generate the intended vulkan ops.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

What's the simplifier rewrite in question?

(rewrite(select(x != y, z, w), select(x == y, w, z)) ||

a future change to the simplifier might make this test silently not generate the intended vulkan ops.

It won't be silently. The test requires OpLogicalNotEqual for != and fails otherwise.

@NekoAsakura

Copy link
Copy Markdown
Author

Oops, missed the Makefile build. Added now.

@NekoAsakura

Copy link
Copy Markdown
Author

CI failed: #9671

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@codecov

codecov Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 73.35%. Comparing base (1b37204) to head (c3d388c).

Files with missing lines Patch % Lines
src/CodeGen_Vulkan_Dev.cpp 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9670      +/-   ##
==========================================
- Coverage   73.44%   73.35%   -0.09%     
==========================================
  Files         266      266              
  Lines       83977    83981       +4     
  Branches    20616    20618       +2     
==========================================
- Hits        61673    61602      -71     
+ Misses      15922    15909      -13     
- Partials     6382     6470      +88     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@derek-gerstmann

Copy link
Copy Markdown
Contributor

@NekoAsakura Looks like there's still test failures on arm32.

@alexreinking alexreinking added backport:pending Needs to be cherry-picked to the active release branch and removed backport labels Nov 29, 2026
@NekoAsakura

Copy link
Copy Markdown
Author

@NekoAsakura Looks like there's still test failures on arm32.

The failures are #9671. So this one needs to go in after #9672.

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

backport:pending Needs to be cherry-picked to the active release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[vulkan] Boolean equality emits invalid OpIEqual instructions

5 participants