Skip to content

Conversation

@jayfoad
Copy link
Contributor

@jayfoad jayfoad commented Apr 2, 2024

  • [AMDGPU] Generate readfirstlane checks
  • [AMDGPU] Add type-generic llvm.amdgcn.readfirstlane2 intrinsic

@jayfoad
Copy link
Contributor Author

jayfoad commented Apr 2, 2024

Prior art:
https://reviews.llvm.org/D84639
https://reviews.llvm.org/D86154
https://reviews.llvm.org/D147732

TODO:

  • GlobalISel
  • readlane, writelane, others?

This patch tries to legalize readfirstlane2 for all legal types, but it should probably work on illegal types like i999 too. Is there a way to implement that for a target intrinsic in SelectionDAG? The only way I could see was with a pre-legalization combine, but I am not sure if it is OK to rely on a combine for legalization.

def int_amdgcn_wave_reduce_umin : AMDGPUWaveReduce;
def int_amdgcn_wave_reduce_umax : AMDGPUWaveReduce;

// i32 llvm.amdgcn.readfirstlane(i32)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should just upgrade the intrinsic instead of introducing a new copy

@@ -1,71 +1,176 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=fiji -verify-machineinstrs < %s | FileCheck -enable-var-scope %s
Copy link
Contributor

Choose a reason for hiding this comment

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

global-isel checks

%x = call float @llvm.amdgcn.readfirstlane2.f32(float %src)
call void asm sideeffect "; use $0", "s"(float %x)
ret void
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Check bfloat, vector bfloat/half, float2, some pointers/pointer vectors

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What is float2? Done the others.

Copy link
Contributor

Choose a reason for hiding this comment

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

<2 x float>

MVT IntVT = MVT::getIntegerVT(VT.getSizeInBits());
return DAG.getBitcast(
VT, DAG.getAnyExtOrTrunc(
DAG.getNode(AMDGPUISD::READFIRSTLANE, DL, MVT::i32,
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe directly accept legal 32-bit types and avoid the bitcast?

@jayfoad
Copy link
Contributor Author

jayfoad commented Oct 30, 2024

Superseded by #89217.

@jayfoad jayfoad closed this Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants