[Openmp-commits] [flang] [compiler-rt] [llvm] [clang-tools-extra] [clang] [libcxxabi] [openmp] [mlir] [libcxx] [libc] [AArch64] Add custom lowering for load <3 x i8>. (PR #78632)

Yingchi Long via Openmp-commits openmp-commits at lists.llvm.org
Fri Jan 26 20:23:14 PST 2024


================
@@ -21248,6 +21297,51 @@ static SDValue foldTruncStoreOfExt(SelectionDAG &DAG, SDNode *N) {
   return SDValue();
 }
 
+// A custom combine to lower load <3 x i8> as the more efficient sequence
+// below:
+//    ldrb wX, [x0, #2]
+//    ldrh wY, [x0]
+//    orr wX, wY, wX, lsl #16
+//    fmov s0, wX
+//
+static SDValue combineV3I8LoadExt(LoadSDNode *LD, SelectionDAG &DAG) {
+  EVT MemVT = LD->getMemoryVT();
+  if (MemVT != EVT::getVectorVT(*DAG.getContext(), MVT::i8, 3) ||
+      LD->getOriginalAlign() >= 4)
+    return SDValue();
+
+  SDLoc DL(LD);
+  MachineFunction &MF = DAG.getMachineFunction();
+  SDValue Chain = LD->getChain();
+  SDValue BasePtr = LD->getBasePtr();
+  MachineMemOperand *MMO = LD->getMemOperand();
+  assert(LD->getOffset().isUndef() && "undef offset expected");
----------------
inclyc wrote:

> Could you share more details? 

I was writing some similar mechanics for `i64`, and assert that `LD->getOffset().isUndef()` while do custom lowering, and I could see miscompilation for SPEC 2017 test suite. It is very large and I'm trying to reduce it.

> We could, but unless we have a test case, I'd prefer to keep it as an assert for now, to give us a chance to catch a test case, if it is possible.

Agreed, maybe just keep it as-is for now

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


More information about the Openmp-commits mailing list