[PATCH] D15604: Changes in conversion cost model for X86 target

Demikhovsky, Elena via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 21 00:07:24 PST 2015


Hi Nadav,

The getTypeLegalizationCost() returns a pair:
Res.first        is a Split-Factor
Res.second is a legal MVT

Let's assume that the original type v4i8. The Res.second will show MVT::4i32. Res.first  = 1.
Now, 4i8 is promoted to 4i32 and you don't know the real cost of this promotion. And the getTypeLegalizationCost() can't provide this information.
Just because it does not know how to promote - sign-extend or zero-extend. 
SITOFP requires sign-extend, UITOFP requires zero-extend.

The real information that we receive from getTypeLegalizationCost() is the split-factor. I use it in the following way:
Example 1:
SSE2:

Sitofp <4 x i32 > %a to <4 x f64>

The split-factor of destination is 2. How do I calculate the cost?

2 * costof (sitofp <2 x i32 > %a to <2 x f64>) + ExtraSplitCost

The ExtraSplitCost is the cost of splitting vector %a.


Example 2:
AVX2:

Sitofp <8 x i64 > %a to <8 x f64>

The split-factor of source and destination is 2. How do I calculate the cost?

2 * costof (sitofp <4 x i64 > %a to <4 x f64>)
The ExtraSplitCost=0 because the source and the destination both come in 2 registers, I don't need any additional shuffle.


Example 3:
SSE2:
Sitofp <4 x i8 > to <4 x f32>
For the source getTypeLegalizationCost() returns (1, MVT::4i32)
 For the dest     getTypeLegalizationCost() returns (1, MVT::4f32)

The original version returns
1 * costof(Sitofp <4 x i32 > to <4 x f32>)
I changed it to
1 * costof(Sitofp <4 x i8 > to <4 x f32>)

Now, after my changes the following  2 operations
Sitofp <4 x i8 > to <4 x f32>
And
Sitofp <4 x i32 > to <4 x f32>
Have the different cost.

The model, I'm proposing does more exact cost estimation. I use getTypeLegalizationCost() for split-factor only.
I can't add one or two lines that I'm missing, because the current model is wrong.
This is the original wrong code:

  > EVT SrcTy = TLI->getValueType(DL, Src);
  > EVT DstTy = TLI->getValueType(DL, Dst);
    
  > // The function getSimpleVT only handles simple value types.
  > if (!SrcTy.isSimple() || !DstTy.isSimple())
  >   return BaseT::getCastInstrCost(Opcode, Dst, Src);

-  Elena


-----Original Message-----
From: Nadav Rotem [mailto:nrotem at apple.com] 
Sent: Monday, December 21, 2015 08:37
To: Demikhovsky, Elena <elena.demikhovsky at intel.com>; hfinkel at anl.gov; Andrea_DiBiagio at sn.scee.net; nrotem at apple.com; congh at google.com; Nuzman, Dorit <dorit.nuzman at intel.com>
Cc: llvm-commits at lists.llvm.org
Subject: Re: [PATCH] D15604: Changes in conversion cost model for X86 target

nadav added a comment.

Elena, I don't understand your comment. getTypeLegalizationCost imitates the type legalizer by splitting and promoting. It actually uses the type legalizer. What do you mean it does not support zero-extend and sign-extend?

Are you saying that it does not handle dag-combine peepholes that we have? Please explain what problem your patch is solving.

I suspect that you can commit changes to the cost table not as part of this patch. But please do not modify the code that uses getTypeLegalizationCost without explaining what it does.


Repository:
  rL LLVM

http://reviews.llvm.org/D15604



---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.


More information about the llvm-commits mailing list