Skip to content

Commit 32e337f

Browse files
sys-igcigcbot
authored andcommitted
[Autobackout][FunctionalRegression]Revert of change: 840a25e: Replace EATOMIC_IADD with EATOMIC_INC and EATOMIC_DEC when
immediate is 1 or -1 as increment or decrement In cases a shader is doing typed atomics with typed, or untyped atomics with ugm, or untyped atomics with slm and just increment or decrement atomic operation using an immediate as -1 and 1, we can use EATOMIC_INC(2) or EATOMIC_DEC(3) to replace EATOMIC_IADD.
1 parent 840a25e commit 32e337f

File tree

3 files changed

+1
-190
lines changed

3 files changed

+1
-190
lines changed

IGC/Compiler/CustomSafeOptPass.cpp

Lines changed: 1 addition & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*========================== begin_copyright_notice ============================
22
3-
Copyright (C) 2017-2025 Intel Corporation
3+
Copyright (C) 2017-2024 Intel Corporation
44
55
SPDX-License-Identifier: MIT
66
@@ -472,66 +472,6 @@ static bool isTruncInvariant(unsigned Opcode) {
472472
}
473473
}
474474

475-
// clang-format off
476-
// In AtomicTyped, convert EATOMIC_IADD(0) to EATOMIC_INC(2) and EATOMIC_DEC(3) when value of 1 is used as increment or -1 as decrement
477-
// From:
478-
// %7 = call i32 @llvm.genx.GenISA.intatomictyped.i32.p2490368__Buffer_Typed_DIM_Resource(%__Buffer_Typed_DIM_Resource addrspace(2490368)* %u01, i32 %ThreadID_X, i32 undef, i32 undef, i32 1, i32 0)
479-
// %8 = call i32 @llvm.genx.GenISA.intatomictyped.i32.p2490368__Buffer_Typed_DIM_Resource(%__Buffer_Typed_DIM_Resource addrspace(2490368)* %u01, i32 %ThreadID_X, i32 undef, i32 undef, i32 -1, i32 0)
480-
// To:
481-
// %7 = call i32 @llvm.genx.GenISA.intatomictyped.i32.p2490368__Buffer_Typed_DIM_Resource(%__Buffer_Typed_DIM_Resource addrspace(2490368)* %u01, i32 %ThreadID_X, i32 undef, i32 undef, i32 1, i32 2)
482-
// %8 = call i32 @llvm.genx.GenISA.intatomictyped.i32.p2490368__Buffer_Typed_DIM_Resource(%__Buffer_Typed_DIM_Resource addrspace(2490368)* %u01, i32 %ThreadID_X, i32 undef, i32 undef, i32 -1, i32 3)
483-
// clang-format on
484-
void CustomSafeOptPass::visitIntAtomicTyped(CallInst *I) {
485-
GenIntrinsicInst *instr = dyn_cast<GenIntrinsicInst>(I);
486-
487-
// for immediate 1 or -1
488-
if (auto *constInt1 = llvm::dyn_cast<llvm::ConstantInt>(instr->getOperand(4))) {
489-
// for atomic_iadd
490-
if (auto *constInt2 = llvm::dyn_cast<llvm::ConstantInt>(instr->getOperand(5))) {
491-
if (AtomicOp::EATOMIC_IADD == constInt2->getZExtValue()) {
492-
if (constInt1->getSExtValue() == 1) {
493-
instr->setOperand(5, llvm::ConstantInt::get(instr->getOperand(5)->getType(), AtomicOp::EATOMIC_INC));
494-
} else if (constInt1->getSExtValue() == -1) {
495-
instr->setOperand(5, llvm::ConstantInt::get(instr->getOperand(5)->getType(), AtomicOp::EATOMIC_DEC));
496-
}
497-
}
498-
}
499-
}
500-
}
501-
502-
// clang-format off
503-
// In AtomicRaw or AtomicRawA64, convert EATOMIC_IADD(0) to EATOMIC_INC(2) and EATOMIC_DEC(3) when value of 1 is used as increment or -1 as decrement
504-
// From:
505-
// %10 = call i32 @llvm.genx.GenISA.intatomicraw.i32.p2490369v4f32(<4 x float> addrspace(2490369)* %u0, i32 %9, i32 1, i32 0)
506-
// %11 = call i32 @llvm.genx.GenISA.intatomicraw.i32.p2490369v4f32(<4 x float> addrspace(2490369)* %u0, i32 %9, i32 -1, i32 0)
507-
// or
508-
// %13 = call i32 @llvm.genx.GenISA.intatomicrawA64.i32.p3i32.p3i32(i32 addrspace(3)* %12, i32 addrspace(3)* %12, i32 1, i32 0)
509-
// %14 = call i32 @llvm.genx.GenISA.intatomicrawA64.i32.p3i32.p3i32(i32 addrspace(3)* %12, i32 addrspace(3)* %12, i32 -1, i32 0)
510-
// To:
511-
// %10 = call i32 @llvm.genx.GenISA.intatomicraw.i32.p2490369v4f32(<4 x float> addrspace(2490369)* %u0, i32 %9, i32 1, i32 2)
512-
// %11 = call i32 @llvm.genx.GenISA.intatomicraw.i32.p2490369v4f32(<4 x float> addrspace(2490369)* %u0, i32 %9, i32 -1, i32 3)
513-
// or
514-
// %13 = call i32 @llvm.genx.GenISA.intatomicrawA64.i32.p3i32.p3i32(i32 addrspace(3)* %12, i32 addrspace(3)* %12, i32 1, i32 2)
515-
// %14 = call i32 @llvm.genx.GenISA.intatomicrawA64.i32.p3i32.p3i32(i32 addrspace(3)* %12, i32 addrspace(3)* %12, i32 -1, i32 3)
516-
// clang-format on
517-
void CustomSafeOptPass::visitIntAtomicRawOrRawA64(CallInst *I) {
518-
GenIntrinsicInst *instr = dyn_cast<GenIntrinsicInst>(I);
519-
520-
// for immediate 1 or -1
521-
if (auto *constInt1 = llvm::dyn_cast<llvm::ConstantInt>(instr->getOperand(2))) {
522-
// for atomic_iadd
523-
if (auto *constInt2 = llvm::dyn_cast<llvm::ConstantInt>(instr->getOperand(3))) {
524-
if (AtomicOp::EATOMIC_IADD == constInt2->getZExtValue()) {
525-
if (constInt1->getSExtValue() == 1) {
526-
instr->setOperand(3, llvm::ConstantInt::get(instr->getOperand(3)->getType(), AtomicOp::EATOMIC_INC));
527-
} else if (constInt1->getSExtValue() == -1) {
528-
instr->setOperand(3, llvm::ConstantInt::get(instr->getOperand(3)->getType(), AtomicOp::EATOMIC_DEC));
529-
}
530-
}
531-
}
532-
}
533-
}
534-
535475
// Searches for following pattern:
536476
// %mul = mul i64 %conv, %conv2
537477
// %conv3 = and i64 %mul, 0xFFFFFFFF
@@ -898,17 +838,6 @@ void CustomSafeOptPass::visitCallInst(CallInst &C) {
898838
break;
899839
}
900840

901-
case GenISAIntrinsic::GenISA_intatomictyped: {
902-
visitIntAtomicTyped(inst);
903-
break;
904-
}
905-
906-
case GenISAIntrinsic::GenISA_intatomicraw:
907-
case GenISAIntrinsic::GenISA_intatomicrawA64: {
908-
visitIntAtomicRawOrRawA64(inst);
909-
break;
910-
}
911-
912841
default:
913842
break;
914843
}

IGC/Compiler/CustomSafeOptPass.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ class CustomSafeOptPass : public llvm::FunctionPass, public llvm::InstVisitor<Cu
7272
void visitSelectInst(llvm::SelectInst &S);
7373
void mergeDotAddToDp4a(llvm::CallInst *I);
7474
void visitTruncInst(llvm::TruncInst &I);
75-
void visitIntAtomicTyped(llvm::CallInst *I);
76-
void visitIntAtomicRawOrRawA64(llvm::CallInst *I);
7775

7876
//
7977
// IEEE Floating point arithmetic is not associative. Any pattern

IGC/Compiler/tests/CustomSafeOptPass/eatomic_iadd_to_inc_dec.ll

Lines changed: 0 additions & 116 deletions
This file was deleted.

0 commit comments

Comments
 (0)