================
@@ -1693,6 +1693,22 @@ getBitTestAtomicOrdering(BitTest::InterlockingKind I) {
   llvm_unreachable("invalid interlocking");
 }
 
+static llvm::Value *EmitIntegerExpr(CodeGenFunction &CGF, const Expr *E) {
+  llvm::Value *ArgValue = CGF.EmitScalarExpr(E);
+  llvm::Type *ArgType = ArgValue->getType();
+
+  if (auto *VT = dyn_cast<llvm::FixedVectorType>(ArgType);
+      VT && VT->getElementType()->isIntegerTy(1)) {
+    llvm::Type *StorageType = CGF.ConvertTypeForMem(E->getType());
+    ArgValue = CGF.emitBoolVecConversion(
+        ArgValue, StorageType->getPrimitiveSizeInBits(), "insertvec");
+    ArgValue = CGF.Builder.CreateBitCast(ArgValue, StorageType);
----------------
rjmccall wrote:

Okay. This is extending `<N x i1>` to `<S x i1>`, where `S` is the storage size 
of the type in bits, and then bitcasting to `iS`, right? So first off, this 
code is assuming that the mem type of a boolean vector is an integer type and 
that LLVM bit-packs boolean vectors, and those are fair assumptions, but 
they're not things that an arbitrary reader will know, so they should be 
clearly spelled out in comments. And second, this is clearly wrong for `clz` 
because the extended bits will be counted.

Also, again, it's not clear to me what the endianness of `clz` / `ctz` is 
supposed to be for vectors, or whether LLVM is guaranteed to match that for a 
bitcasted `<N x i1>`.

Also, `emitBoolVecConversion` appears to use `PoisonMaskElem` (-1) for the 
excess elements, so I don't think you can correctly use this for any of these 
operations.

https://github.com/llvm/llvm-project/pull/154203
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to