[PATCH] D133300: [InstCombine] Matrix multiplication negation optimisation

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 11 08:48:13 PDT 2022


spatel added a comment.

In D133300#3781177 <https://reviews.llvm.org/D133300#3781177>, @zjaffal wrote:

> - In the cases where both operands are negated we may need to introduce a seperate patch to handle that case

Yes, and it should be written first. Without it, we have inconsistent behavior. This patch will reduce the 2nd example below, but it misses the 1st even though they are very similar patterns:

  define <9 x double> @test_with_two_operands_negated2_commute(<3 x double> %a, <27 x double> %b){
    %a.neg = fneg <3 x double> %a
    %b.neg = fneg <27 x double> %b
    %res = call <9 x double> @llvm.matrix.multiply.v9f64.v3f64.v27f64(<3 x double> %a.neg, <27 x double> %b.neg, i32 1, i32 3, i32 9)
    ret <9 x double> %res
  }
  
  define <9 x double> @test_with_two_operands_negated2(<27 x double> %a, <3 x double> %b){
    %a.neg = fneg <27 x double> %a
    %b.neg = fneg <3 x double> %b
    %res = tail call <9 x double> @llvm.matrix.multiply.v9f64.v27f64.v3f64(<27 x double> %a.neg, <3 x double> %b.neg, i32 9, i32 3, i32 1)
    ret <9 x double> %res
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133300



More information about the llvm-commits mailing list