The GitHub Actions job "Lint" on tvm.git/main has succeeded.
Run started by GitHub user tlopex (triggered by tlopex).

Head commit for run:
a04087f5e49b04a2c748d4624417eef9e46c55e4 / HeJun <[email protected]>
[Fix][Codegen] Avoid extraneous parentheses in if_then_else generated code 
(#20285)

## Problem

Since #16242, the `if_then_else` builtin call is expanded into an
if/else statement. When printing the condition, the codegen wraps it in
another pair of parentheses even though it is already parenthesized,
producing `if ((i == 0))`.

## Impact

The doubled parentheses trigger clang's `-Wparentheses-equality` warning
under `-Wall`/`-Wparentheses`, which is noisy for downstream users who
compile TVM-generated C sources with strict warning settings.
Correctness is not affected — the issue is cosmetic.

## Solution

Reuse the same leading/trailing parenthesis check as the existing
`IfThenElseNode` handling in `CodeGenC`, so a condition that already
starts and ends with parentheses is printed as-is. The generated code
now reads `if (i == 0)`.

Since `CodeGenC` is the shared base of all C-style backends (CUDA,
Metal, ROCm, Vulkan, WebGPU, Hexagon), this fix covers them all at once.

## Testing

- Added a regression test
`test_if_then_else_avoids_extraneous_parentheses` in
`tests/python/codegen/test_target_codegen_c_host.py`, which asserts the
generated C source contains no `if ((` and validates the runtime result.
- Ran the full `test_target_codegen_c_host.py` suite on aarch64 Linux
with a local build: 10/10 passed.
- `pre-commit` (clang-format, ruff-check, ruff-format) passed on the
changed files.

Co-authored-by: hejun <[email protected]>

Report URL: https://github.com/apache/tvm/actions/runs/34517236735

With regards,
GitHub Actions via GitBox


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to