[clang] [llvm] [X86][AVX512] rematerialize smaller predicate masks (PR #166178)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 3 07:43:36 PST 2025


================
@@ -3173,6 +3179,26 @@ let Predicates = [HasAVX512] in {
   def : Pat<(v1i1 immAllOnesV),  (COPY_TO_REGCLASS (KSET1W), VK1)>;
 }
 
+// With AVX512DQ, use 8-bit operations for 8-bit masks to avoid setting upper
+// bits
+let Predicates = [HasDQI] in {
+  def : Pat<(v8i1 immAllZerosV), (KSET0B)>;
+  def : Pat<(v8i1 immAllOnesV), (KSET1B)>;
+}
+
+// Optimize bitconvert of all-ones constants to use kxnor instructions
+let Predicates = [HasDQI] in {
+  def : Pat<(v8i1(bitconvert(i8 255))), (KSET1B)>;
+  def : Pat<(v16i1(bitconvert(i16 255))), (COPY_TO_REGCLASS(KSET1B), VK16)>;
+}
+let Predicates = [HasAVX512] in {
+  def : Pat<(v16i1(bitconvert(i16 65535))), (KSET1W)>;
----------------
RKSimon wrote:

redundant?

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


More information about the llvm-commits mailing list