Skip to content

Conversation

@wenju-he
Copy link
Contributor

When pointer element type is casted to integer type, the stored value should be casted to integer type to avoid type mistmatch. LLVM IR change in function _Z18__clc_atomic_storePU3AS1Vffii:
> %5 = bitcast float %1 to i32 (New)
< %5 = fptosi float %1 to i32 (Old)

When pointer element type is casted to integer type, the stored value
should be casted to integer type to avoid type mistmatch.
LLVM IR change in function _Z18__clc_atomic_storePU3AS1Vffii:
    >   %5 = bitcast float %1 to i32   (New)
    <   %5 = fptosi float %1 to i32    (Old)
@llvmbot llvmbot added the libclc libclc OpenCL library label Nov 12, 2025
@wenju-he wenju-he requested a review from Copilot November 12, 2025 02:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a type mismatch in the __clc_atomic_store function for floating-point types. The issue occurs when a floating-point pointer is cast to an integer pointer type, but the stored value wasn't being properly converted from floating-point to integer representation using bitcast semantics.

  • Introduces __CLC_AS_INTTYPE macro to properly cast the stored value to match the pointer's cast type
  • Applies the integer type conversion to the Value parameter in atomic store operations

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
libclc/clc/lib/generic/atomic/clc_atomic_store.cl Defines __CLC_AS_INTTYPE macro to enable proper type conversion for atomic store values
libclc/clc/lib/generic/atomic/clc_atomic_def.inc Adds default __CLC_AS_INTTYPE macro definition and applies it to the Value parameter in the store operation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@wenju-he wenju-he changed the title [libclc] Fix floating-point __clc_atomic_store cast mismatch [libclc] Fix floating-point __clc_atomic_store/exchange cast mismatch Nov 12, 2025
@wenju-he wenju-he merged commit fa417d7 into llvm:main Nov 13, 2025
10 checks passed
@wenju-he wenju-he deleted the libclc-clc_atomic_store branch November 13, 2025 00:03
git-crd pushed a commit to git-crd/crd-llvm-project that referenced this pull request Nov 13, 2025
…llvm#167625)

When pointer element type is casted to integer type, the stored value
should be casted to integer type to avoid type mistmatch. LLVM IR change
in function _Z18__clc_atomic_storePU3AS1Vffii:
    >   %5 = bitcast float %1 to i32   (New)
    <   %5 = fptosi float %1 to i32    (Old)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libclc libclc OpenCL library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants