[PATCH] D128123: [SDAG] try to replace subtract-from-constant with xor

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 27 04:42:33 PDT 2022


foad added inline comments.


================
Comment at: llvm/test/CodeGen/AMDGPU/ds-sub-offset.ll:132
+; GFX10-NEXT:    ds_write_b8 v0, v1
 ; GFX10-NEXT:    s_endpgm
   %x.i = call i32 @llvm.amdgcn.workitem.id.x() #0
----------------
deadalnix wrote:
> spatel wrote:
> > RKSimon wrote:
> > > RKSimon wrote:
> > > > Based off @foad's comments on D128080 - we need to either add a TLI override to control this or add a way for AMDGPU to reverse it.
> > > Hmm - how similar is TargetLowering::preferIncOfAddToSubOfNot ?
> > At first glance, that seems more about constant materialization while this is about a "sub-from" instruction with an immediate operand. 
> > 
> > That hook is default true but overridden to false for vector types by ARM/AArch/PowerPC.
> TBH, it seems like a missed opportunity from the AMDGPU backend rather than a major problem with this patch.
> 
> Isn't there someone from AMD we can get help from here?
AMDGPUDAGToDAGISel::SelectDS1Addr1Offset would have to be taught to match appropriate uses of ISD::XOR as well as ISD::SUB (similar to how addressing mode matchers have to match OR as well as ADD?). This code was added by @arsenm in D12283. It doesn't sound like a very important real world use case so maybe we could just ignore the regression?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D128123/new/

https://reviews.llvm.org/D128123



More information about the llvm-commits mailing list