[llvm] [AMDGPU] Optimize fcanonicalize/fneg/fsub with packed bf16 math ops (PR #197318)

Changpeng Fang via llvm-commits llvm-commits at lists.llvm.org
Wed May 13 10:49:36 PDT 2026


changpeng wrote:

> Also, this should really touch min and max in a fully separate change from any other FP operation

Agreed! We should work on these min/max to eliminate unnecessary canonicalizations with recent hardwares.
So, for this case of packed bfloat, I am keeping FMINNUM/FMAX 'Legal; as it was (before the patch. And the remaining optimizations are
1) make fcanonocalize 'Legal", and use v_max_num_nf16 to implement the selection pattern.
2) make FNEG legal to 
    a) Allow fneg to be folded into the packed bf16 ops
    b) Select v_pk_add_bf16 for fsub bf16 vectors

Need to investigate min/max further as separate work. 

https://github.com/llvm/llvm-project/pull/197318


More information about the llvm-commits mailing list