llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.18k stars 11.13k forks source link

Arbitrary Constant Operands vs. 0 #87775

Open tschuett opened 3 months ago

tschuett commented 3 months ago

According to the Mir pattern guide immediates can be a named constant, i.e., 0 or 1. We cannot express that an immediate is constant without committing to the value.

def extract_vector_element_shuffle_vector : GICombineRule<
   (defs root:$root, build_fn_matchinfo:$matchinfo),
   (match (G_SHUFFLE_VECTOR $src, $src1, $src2, $mask),
          (G_EXTRACT_VECTOR_ELT $root, $src, $idx),
   [{ return Helper.matchExtractVectorElementWithShuffleVector(${root}, ${matchinfo}); }]),
   (apply [{ Helper.applyBuildFnMO(${root}, ${matchinfo}); }])>;

This combine can only succeed, if $idx is constant.

Pierre-vh commented 3 months ago

We cannot express that an immediate is constant without committing to the value.

What do you mean? Is this about the distinction between imm/CImm?

tschuett commented 3 months ago

I could replace $idx by zero. But then I would have to copy-paste with 1, 2, 3, 4, ... I am not interested, which value $idx has as long as it is constant.