[llvm-dev] Cost model is missing in InstCombiner

Shixiong Xu via llvm-dev llvm-dev at lists.llvm.org
Wed Aug 17 03:48:59 PDT 2016


Hi,

I think canEvaluateTruncated() in InstCombiner needs use cost model to decide whether perform optimization or not.  Without cost model from TargetTransformInfo, aggressively optimizing IR in vector types according to the number of bits demanded may lead to scalarization of vector operations. For example, if the input IR is:

  %wide.load25 = load <32 x i8>, <32 x i8>* %231, align 1
  %232 = zext <32 x i8> %wide.load25 to <32 x i16>
  %233 = mul nuw nsw <32 x i16> %232, %164
  ...
  %237 = trunc <32 x i16> %233 to <32 x i8>
  store <32 x i8> %237, <32 x i8>* %236, align 1

ICE: EvaluateInDifferentType converting expression type to avoid cast:   %9 = trunc <32 x i16> %6 to <32 x i8>
IC: ADD:   %6 = mul <32 x i8> %wide.load25, %wide.load
IC: Replacing   %10 = trunc <32 x i16> %7 to <32 x i8>
    with   %6 = mul <32 x i8> %wide.load25, %wide.load

If the target doesn't have support for mul <32 x i8>, the inst combiner will yield less profitable code.

Cheers,

Shixiong (Jason) Xu

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160817/961996b5/attachment.html>


More information about the llvm-dev mailing list