Carrot Wei via llvm-dev
2020-May-27 17:04 UTC
[llvm-dev] [cfe-dev] [RFC] Loading Bitfields with Smallest Needed Types
> Similar issue with aligned extload widening. The load and store are both > i16 in IR.> struct s { > int x; // force alignment > short y; > };> void g(); > short f2(s *a, short b) { > a->y = b; > g(); > return a->y - b; > }> produces this > movq %rdi, %rbx > movw %bp, 4(%rdi) // 2 byte store > callq g() > movl 4(%rbx), %eax // 4 byte load > subl %ebp, %eax> ~CraigIt is caused by loadi32: def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{ LoadSDNode *LD = cast<LoadSDNode>(N); ISD::LoadExtType ExtType = LD->getExtensionType(); if (ExtType == ISD::NON_EXTLOAD) return true; if (ExtType == ISD::EXTLOAD) // * return LD->getAlignment() >= 4 && LD->isSimple(); // * return false; }]>; Without the commented lines, movzwl should be generated. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200527/28813681/attachment.html>