================
@@ -1549,10 +1583,31 @@ CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID, 
const CallExpr *expr) {
   case X86::BI__builtin_ia32_selectpd_128:
   case X86::BI__builtin_ia32_selectpd_256:
   case X86::BI__builtin_ia32_selectpd_512:
+    return emitX86Select(builder, getLoc(expr->getExprLoc()), ops[0], ops[1],
+                         ops[2]);
   case X86::BI__builtin_ia32_selectsh_128:
   case X86::BI__builtin_ia32_selectsbf_128:
   case X86::BI__builtin_ia32_selectss_128:
-  case X86::BI__builtin_ia32_selectsd_128:
+  case X86::BI__builtin_ia32_selectsd_128: {
+    mlir::Location loc = getLoc(expr->getExprLoc());
+
+    // Extract scalar elements from vector operands
+    mlir::Value scalar1 = ops[1];
+    mlir::Value scalar2 = ops[2];
+    if (auto vecTy = mlir::dyn_cast<cir::VectorType>(ops[1].getType()))
----------------
Priyanshu3820 wrote:

> Are there cases where these are not vectors?

I gave it some more thought. At first when I had seen the classic codegen 
implementation, I had thought they should also have a defensive code to process 
scalar inputs . I thought that was something missing there so I should add that 
here. But now I came to see why classic codegen doesn't do that and that's 
because-
1. These intrinsics are just not supposed to work on scalar inputs.
2. The way I had implemented it, it would have returned scalar output.
That's why I have decided to remove it. Now, it only processes vector cases.

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

Reply via email to