[llvm-branch-commits] [llvm] ARM: Remove unnecessary use_empty check (PR #137338)

2025-04-25 Thread Tim Gymnich via llvm-branch-commits

https://github.com/tgymnich approved this pull request.


https://github.com/llvm/llvm-project/pull/137338
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [AMDGPU] New RegBankSelect: Add missing S/VGPR pointer types (PR #142600)

2025-06-03 Thread Tim Gymnich via llvm-branch-commits

https://github.com/tgymnich approved this pull request.


https://github.com/llvm/llvm-project/pull/142600
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [llvm] [AMDGPU] New RegBankSelect: Add missing S/VGPR pointer types (PR #142600)

2025-06-03 Thread Tim Gymnich via llvm-branch-commits

tgymnich wrote:

maybe add tests?

https://github.com/llvm/llvm-project/pull/142600
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [GIselValueTracking] Correctly truncate/zext G_PTRTOADDR (PR #143816)

2025-06-12 Thread Tim Gymnich via llvm-branch-commits

https://github.com/tgymnich approved this pull request.


https://github.com/llvm/llvm-project/pull/143816
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [WIP] Introduce a G_PTRTOADDR GIsel node (PR #140300)

2025-06-12 Thread Tim Gymnich via llvm-branch-commits


@@ -7407,6 +7412,34 @@ LegalizerHelper::LegalizeResult 
LegalizerHelper::lowerTRUNC(MachineInstr &MI) {
   return UnableToLegalize;
 }
 
+LegalizerHelper::LegalizeResult
+LegalizerHelper::lowerPTRTOADDR(MachineInstr &MI) {
+  // Lower G_PTRTOADDR as a truncate to address width of G_PTROINT and then
+  // zero extend to the target width if there is no native support for it.
+  MachineRegisterInfo &MRI = *MIRBuilder.getMRI();
+  const DataLayout &DL = MIRBuilder.getDataLayout();
+  assert(MI.getOpcode() == TargetOpcode::G_PTRTOADDR);
+  auto DstReg = MI.getOperand(0).getReg();
+  auto SrcReg = MI.getOperand(1).getReg();
+  LLT SrcTy = MRI.getType(SrcReg);
+
+  LLT AddrTy = getLLTForType(
+  *DL.getAddressType(MIRBuilder.getContext(), SrcTy.getAddressSpace()), 
DL);
+  LLT IntPtrTy = getLLTForType(
+  *DL.getIntPtrType(MIRBuilder.getContext(), SrcTy.getAddressSpace()), DL);
+  if (SrcTy.isVector()) {
+AddrTy = LLT::vector(SrcTy.getElementCount(), AddrTy);
+IntPtrTy = LLT::vector(SrcTy.getElementCount(), IntPtrTy);
+  }
+  auto PtrToInt = MIRBuilder.buildPtrToInt(IntPtrTy, SrcReg);
+  auto Addr = PtrToInt;
+  if (AddrTy != IntPtrTy)
+Addr = MIRBuilder.buildTrunc(AddrTy, PtrToInt.getReg(0));
+  MIRBuilder.buildZExtOrTrunc(DstReg, Addr.getReg(0));

tgymnich wrote:

```suggestion
  Register Addr = MIRBuilder.buildPtrToInt(IntPtrTy, SrcReg).getReg(0);
  if (AddrTy != IntPtrTy)
Addr = MIRBuilder.buildTrunc(AddrTy,  Addr).getReg(0);
  MIRBuilder.buildZExtOrTrunc(DstReg, Addr);
```

https://github.com/llvm/llvm-project/pull/140300
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [WIP] Introduce a G_PTRTOADDR GIsel node (PR #140300)

2025-06-12 Thread Tim Gymnich via llvm-branch-commits


@@ -7407,6 +7412,34 @@ LegalizerHelper::LegalizeResult 
LegalizerHelper::lowerTRUNC(MachineInstr &MI) {
   return UnableToLegalize;
 }
 
+LegalizerHelper::LegalizeResult
+LegalizerHelper::lowerPTRTOADDR(MachineInstr &MI) {
+  // Lower G_PTRTOADDR as a truncate to address width of G_PTROINT and then

tgymnich wrote:

```suggestion
  // Lower G_PTRTOADDR as a truncate to address width of G_PTRTOINT and then
```

https://github.com/llvm/llvm-project/pull/140300
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [WIP] Introduce a G_PTRTOADDR GIsel node (PR #140300)

2025-06-12 Thread Tim Gymnich via llvm-branch-commits


@@ -7407,6 +7412,34 @@ LegalizerHelper::LegalizeResult 
LegalizerHelper::lowerTRUNC(MachineInstr &MI) {
   return UnableToLegalize;
 }
 
+LegalizerHelper::LegalizeResult
+LegalizerHelper::lowerPTRTOADDR(MachineInstr &MI) {
+  // Lower G_PTRTOADDR as a truncate to address width of G_PTROINT and then
+  // zero extend to the target width if there is no native support for it.
+  MachineRegisterInfo &MRI = *MIRBuilder.getMRI();
+  const DataLayout &DL = MIRBuilder.getDataLayout();
+  assert(MI.getOpcode() == TargetOpcode::G_PTRTOADDR);
+  auto DstReg = MI.getOperand(0).getReg();
+  auto SrcReg = MI.getOperand(1).getReg();

tgymnich wrote:

```suggestion
  Register DstReg = MI.getOperand(0).getReg();
  Register SrcReg = MI.getOperand(1).getReg();
```

https://github.com/llvm/llvm-project/pull/140300
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [AMDGPU] Baseline test for ptrtoaddr code generation (PR #143813)

2025-06-12 Thread Tim Gymnich via llvm-branch-commits

https://github.com/tgymnich approved this pull request.


https://github.com/llvm/llvm-project/pull/143813
___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits