[llvm] [Xtensa] Implement lowering Mul/Div/Shift operations. (PR #99981)

Sergei Barannikov via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 26 11:08:33 PDT 2024


================
@@ -662,15 +690,33 @@ SDValue XtensaTargetLowering::getAddrPCRel(SDValue Op,
   return DAG.getNode(XtensaISD::PCREL_WRAPPER, DL, Ty, Op);
 }
 
-SDValue XtensaTargetLowering::LowerConstantPool(ConstantPoolSDNode *CP,
+SDValue XtensaTargetLowering::LowerConstantPool(SDValue Op,
                                                 SelectionDAG &DAG) const {
-  EVT PtrVT = getPointerTy(DAG.getDataLayout());
+  EVT PtrVT = Op.getValueType();
+  ConstantPoolSDNode *CP = cast<ConstantPoolSDNode>(Op);
+  auto C = const_cast<Constant *>(CP->getConstVal());
+  auto T = CP->getType();
   SDValue Result;
-  if (!CP->isMachineConstantPoolEntry()) {
-    Result = DAG.getTargetConstantPool(CP->getConstVal(), PtrVT, CP->getAlign(),
-                                       CP->getOffset());
+
+  // Do not use constant pool for aggregate or vector constant types,
+  // in such cases create global variable, for example to store tabel
+  // when we lower CTTZ operation.
----------------
s-barannikov wrote:

It may make sense to not use this "table lookup" expansion at all and custom lower CTTZ_ZERO_UNDEF to a libcall.
Alternatively, you can custom lower CTPOP to a libcall, in which case CTTZ_ZERO_UNDEF will be expanded as `popcount(~x & (x - 1))`.


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


More information about the llvm-commits mailing list