Skip to content

[HLSL] vector float to int and vec int to float are asserting #82826

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
farzonl opened this issue Feb 23, 2024 · 1 comment · Fixed by #82827
Closed

[HLSL] vector float to int and vec int to float are asserting #82826

farzonl opened this issue Feb 23, 2024 · 1 comment · Fixed by #82827
Assignees
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" HLSL HLSL Language Support

Comments

@farzonl
Copy link
Member

farzonl commented Feb 23, 2024

void Fn( int64_t2 p0);

void Call1(half2 p0) {
  Fn3(p0);
}

void Call2(float2 p0) {
  Fn3(p0);
}

doing an int cast when we need to be doing sitofp

static CastInst *llvm::CastInst::Create(Instruction::CastOps, Value *, Type *, const Twine &, Instruction *): Assertion `castIsValid(op, S, Ty) && "Invalid cast!"' failed.
#10 0x000055690b7b06b1 llvm::CastInst::Create(llvm::Instruction::CastOps, llvm::Value*, llvm::Type*, llvm::Twine const&, llvm::Instruction*) /mnt/DevDrive/projects/llvm-project/llvm/lib/IR/Instructions.cpp:3331:11
#11 0x00005569085869fa llvm::IRBuilderBase::CreateCast(llvm::Instruction::CastOps, llvm::Value*, llvm::Type*, llvm::Twine const&) /mnt/DevDrive/projects/llvm-project/llvm/include/llvm/IR/IRBuilder.h:2150:19
#12 0x0000556908589832 llvm::IRBuilderBase::CreateIntCast(llvm::Value*, llvm::Type*, bool, llvm::Twine const&) /mnt/DevDrive/projects/llvm-project/llvm/include/llvm/IR/IRBuilder.h:2185:5
void Fn4( float2 p0);

void Call5(int64_t2 p0) {
  Fn4(p0);
}

Need to be doing an int to float cast but we are doing a float to int

#10 0x0000563efc7c7fa1 llvm::CastInst::Create(llvm::Instruction::CastOps, llvm::Value*, llvm::Type*, llvm::Twine const&, llvm::Instruction*) /mnt/DevDrive/projects/llvm-project/llvm/lib/IR/Instructions.cpp:3331:11
#11 0x0000563ef958dfba llvm::IRBuilderBase::CreateCast(llvm::Instruction::CastOps, llvm::Value*, llvm::Type*, llvm::Twine const&) /mnt/DevDrive/projects/llvm-project/llvm/include/llvm/IR/IRBuilder.h:2150:19
#12 0x0000563ef9866f2f llvm::IRBuilderBase::CreateFPToUI(llvm::Value*, llvm::Type*, llvm::Twine const&) /mnt/DevDrive/projects/llvm-project/llvm/include/llvm/IR/IRBuilder.h:2060:5
@EugeneZelenko EugeneZelenko added HLSL HLSL Language Support and removed new issue labels Feb 23, 2024
farzonl added a commit to farzonl/llvm-project that referenced this issue Feb 23, 2024
There are two issues here. first ICK_Floating_Integral were always
defaulting to CK_FloatingToIntegral for vectors regardless of  direction
of cast. Check was scalar only so added a vec float check to the
conditional.
Second issue was float to int  casts were resolving to ICK_Integral_Promotion
when they need to be resolving to CK_FloatingToIntegral. This was fixed
by changing the ordering of conversion checks.

This fixes llvm#82826
farzonl added a commit to farzonl/llvm-project that referenced this issue Feb 23, 2024
There are two issues here. first ICK_Floating_Integral were always
defaulting to CK_FloatingToIntegral for vectors regardless of  direction
of cast. Check was scalar only so added a vec float check to the
conditional.
Second issue was float to int  casts were resolving to ICK_Integral_Promotion
when they need to be resolving to CK_FloatingToIntegral. This was fixed
by changing the ordering of conversion checks.

This fixes llvm#82826
llvm-beanz pushed a commit that referenced this issue Feb 26, 2024
There are two issues here. first `ICK_Floating_Integral` were always
defaulting to `CK_FloatingToIntegral` for vectors regardless of
direction of cast. Check was scalar only so added a vec float check to
the conditional.

Second issue was float to int casts were resolving to
ICK_Integral_Promotion when they need to be resolving to
CK_FloatingToIntegral. This was fixed by changing the ordering of
conversion checks.

This fixes #82826
@EugeneZelenko EugeneZelenko added the clang:frontend Language frontend issues, e.g. anything involving "Sema" label Feb 26, 2024
@llvmbot
Copy link
Member

llvmbot commented Feb 26, 2024

@llvm/issue-subscribers-clang-frontend

Author: Farzon Lotfi (farzonl)

```hlsl void Fn( int64_t2 p0);

void Call1(half2 p0) {
Fn3(p0);
}

void Call2(float2 p0) {
Fn3(p0);
}

doing an int cast when we need to be doing sitofp

static CastInst llvm::CastInst::Create(Instruction::CastOps, Value , Type , const Twine &, Instruction ): Assertion `castIsValid(op, S, Ty) && "Invalid cast!"' failed.
#10 0x000055690b7b06b1 llvm::CastInst::Create(llvm::Instruction::CastOps, llvm::Value
, llvm::Type
, llvm::Twine const&, llvm::Instruction
) /mnt/DevDrive/projects/llvm-project/llvm/lib/IR/Instructions.cpp:3331:11
#11 0x00005569085869fa llvm::IRBuilderBase::CreateCast(llvm::Instruction::CastOps, llvm::Value
, llvm::Type*, llvm::Twine const&) /mnt/DevDrive/projects/llvm-project/llvm/include/llvm/IR/IRBuilder.h:2150:19
#12 0x0000556908589832 llvm::IRBuilderBase::CreateIntCast(llvm::Value*, llvm::Type*, bool, llvm::Twine const&) /mnt/DevDrive/projects/llvm-project/llvm/include/llvm/IR/IRBuilder.h:2185:5


```hlsl
void Fn4( float2 p0);

void Call5(int64_t2 p0) {
  Fn4(p0);
}

Need to be doing an int to float cast but we are doing a float to int

#<!-- -->10 0x0000563efc7c7fa1 llvm::CastInst::Create(llvm::Instruction::CastOps, llvm::Value*, llvm::Type*, llvm::Twine const&amp;, llvm::Instruction*) /mnt/DevDrive/projects/llvm-project/llvm/lib/IR/Instructions.cpp:3331:11
#<!-- -->11 0x0000563ef958dfba llvm::IRBuilderBase::CreateCast(llvm::Instruction::CastOps, llvm::Value*, llvm::Type*, llvm::Twine const&amp;) /mnt/DevDrive/projects/llvm-project/llvm/include/llvm/IR/IRBuilder.h:2150:19
#<!-- -->12 0x0000563ef9866f2f llvm::IRBuilderBase::CreateFPToUI(llvm::Value*, llvm::Type*, llvm::Twine const&amp;) /mnt/DevDrive/projects/llvm-project/llvm/include/llvm/IR/IRBuilder.h:2060:5

@farzonl farzonl assigned farzonl and unassigned davidcook-msft Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" HLSL HLSL Language Support
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants