[PATCH] D98081: [AMDGPU] Improve Codegen for build_vector

Julien Pagès via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 10 15:58:07 PDT 2021


jpages added inline comments.


================
Comment at: llvm/lib/Target/AMDGPU/AMDGPUInstructions.td:188
 
+class is_canonicalized<SDPatternOperator op> : PatFrag<
+  (ops node:$src0, node:$src1),
----------------
foad wrote:
> This frag matches: a binary operator whose inputs are both canonicalized.
> 
> I think would be cleaner to have a frag (maybe a PatLeaf?) that matches just: a node that is canonicalized. Then instead of a pattern like "is_canonicalized<build_vector> src0, src1" you would write "build_vector (is_canonicalized src0), (is_canonicalized src1)". Unfortunately my TableGen skills are not great, so I don't know exactly how to implement this.
I tried to do it as you suggested. My tableGen skills are not great so maybe there is the way but I couldn't find it.

>From my understanding:
- A PatLeaf can not have an argument so I can't write `is_canonicalized $src`
- The only solution seems to use a PatFrag instead
- I have to give a "type" to such a PatFrag, as well as specifying the number of parameters. I tried to do something generic but the unary pattern looked like that `is_canonicalized_unary<BitConvert>` or some other SDNode with only one operand. 




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

https://reviews.llvm.org/D98081



More information about the llvm-commits mailing list