<div dir="ltr"><div class="gmail_default" style="font-size:small"><pre style="white-space:pre-wrap;color:rgb(0,0,0)">> 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

> ~Craig</pre><pre style="white-space:pre-wrap;color:rgb(0,0,0)"><br></pre><pre style="white-space:pre-wrap;color:rgb(0,0,0)">It is caused by loadi32:</pre><pre style="white-space:pre-wrap;color:rgb(0,0,0)"><br></pre><pre style="white-space:pre-wrap;color:rgb(0,0,0)">def loadi32 : PatFrag<(ops node:$ptr), (i32 (unindexedload node:$ptr)), [{<br>  LoadSDNode *LD = cast<LoadSDNode>(N);<br>  ISD::LoadExtType ExtType = LD->getExtensionType();<br>  if (ExtType == ISD::NON_EXTLOAD)<br>    return true;<br>  if (ExtType == ISD::EXTLOAD)                                  // *<br>    return LD->getAlignment() >= 4 && LD->isSimple();           // *<br>  return false;<br>}]>;<br></pre><pre style="white-space:pre-wrap;color:rgb(0,0,0)"><br></pre><pre style="white-space:pre-wrap;color:rgb(0,0,0)">Without the commented lines, movzwl should be generated.</pre><pre style="white-space:pre-wrap;color:rgb(0,0,0)"><br></pre></div></div>