================
@@ -1066,6 +1066,12 @@ InstructionCost GCNTTIImpl::getCastInstrCost(unsigned 
Opcode, Type *Dst,
         Elts && Src->isIntegerTy(*Elts))
       return InstructionCost(MaskUnpackCostPerElt) * *Elts *
              getFullRateInstrCost();
+    // Integer and floating-point values share the same registers, so a bitcast
+    // between legal types is free. A legalized type, such as a vector of i8,
+    // may need its lanes repacked.
+    if (TLI->isTypeLegal(TLI->getValueType(DL, Src)) &&
+        TLI->isTypeLegal(TLI->getValueType(DL, Dst)))
----------------
michaelselehov wrote:

Thanks, you are right. I reproduced it, and it is wider than this case: every 
bitcast between an i1 mask and a vector of legal elements got cheaper on all 
targets. For example, `<64 x i1> -> <2 x float>` went from 2 to 0, and `<2 x 
float> -> <64 x i1>` went from 128 to 64. With the size check all of them 
return to the costs on main. I added the check with a comment on why the sizes 
can differ, and an `i1_mask` test with your case.


https://github.com/llvm/llvm-project/pull/238412
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to