Skip to content

Commit

Permalink
Correct conditions for Legalization and AddrSpaceCastFixing
Browse files Browse the repository at this point in the history
  * Legalization: limit Frem legalization to single precision
  * AddrSpaceCastFixing: fix for fuzzer test case
  • Loading branch information
dguzhaev authored and igcbot committed Nov 26, 2024
1 parent cc7326c commit 2e759fb
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
2 changes: 1 addition & 1 deletion IGC/Compiler/CISACodeGen/FixAddrSpaceCast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ bool AddrSpaceCastFixing::fixCase1(Instruction* I, BasicBlock::iterator& BI) con
// Find the eligible pair of `ptrtoint`/`inttoptr` and convert them back
// to `addrspacecast`.
IntToPtrInst* I2P = dyn_cast<IntToPtrInst>(I);
if (!I2P)
if (!I2P || !I2P->getType()->isPointerTy())
return false;
PointerType* DstPtrTy = cast<PointerType>(I2P->getType());
PtrToIntInst* P2I = dyn_cast<PtrToIntInst>(I2P->getOperand(0));
Expand Down
2 changes: 1 addition & 1 deletion IGC/Compiler/LegalizationPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ void Legalization::visitUnaryInstruction(UnaryInstruction &I) {

void Legalization::visitBinaryOperator(llvm::BinaryOperator& I)
{
if (I.getOpcode() == Instruction::FRem)
if (I.getOpcode() == Instruction::FRem && I.getType()->isFloatTy())
{
Function* floorFunc =
Intrinsic::getDeclaration(m_ctx->getModule(), Intrinsic::floor, I.getType());
Expand Down
20 changes: 20 additions & 0 deletions IGC/Compiler/tests/FixAddrSpaceCast/i2p-vec-typed-pointers.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
;=========================== begin_copyright_notice ============================
;
; Copyright (C) 2024 Intel Corporation
;
; SPDX-License-Identifier: MIT
;
;============================ end_copyright_notice =============================
; COM: check that vector of pointers compiles wo assert
; RUN: igc_opt --igc-addrspacecast-fix -S < %s
; ------------------------------------------------
; FixAddrSpaceCast
; ------------------------------------------------

define spir_kernel void @test(<8 x i32> %payloadHeader) {
entry:
%C = inttoptr <8 x i32> undef to <8 x i32*>
store <8 x i32*> %C, <8 x i32*>* null, align 64
ret void
}

21 changes: 21 additions & 0 deletions IGC/Compiler/tests/FixAddrSpaceCast/i2p-vec.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
;=========================== begin_copyright_notice ============================
;
; Copyright (C) 2024 Intel Corporation
;
; SPDX-License-Identifier: MIT
;
;============================ end_copyright_notice =============================
; REQUIRES: llvm-14-plus
; COM: check that vector of pointers compiles wo assert
; RUN: igc_opt --opaque-pointers --igc-addrspacecast-fix -S < %s
; ------------------------------------------------
; FixAddrSpaceCast
; ------------------------------------------------

define spir_kernel void @test(<8 x i32> %payloadHeader) {
entry:
%C = inttoptr <8 x i32> undef to <8 x ptr>
store <8 x ptr> %C, ptr null, align 64
ret void
}

0 comments on commit 2e759fb

Please sign in to comment.