<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Perhaps "(*b)[2]" is out of bounds?</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Apr 27, 2020 at 8:57 PM Panyuntao(Compiler) via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">





<div lang="ZH-CN">
<div class="gmail-m_-8138766083693493927WordSection1">
<p class="MsoNormal"><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(102,102,102)">Hi, All developers:<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(102,102,102)"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(102,102,102)">I have this code. For (*b)[2], It is reasonable that llvm thinks it's unaligned access. and I think the array pointer always points to 4 - byte aligned
 array elements.<u></u><u></u></span></b></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><img width="192" height="82" id="gmail-m_-8138766083693493927_x56fe__x7247__x0020_1" src="cid:171c1b439c04cff311"></span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(102,102,102)">CMD: clang  --target=arm-none-eabi -mcpu=cortex-r52 -mthumb -O0 -emit-llvm -S test.c -o test.ll<u></u><u></u></span></p>
<p class="MsoNormal"><b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(102,102,102)">LLVM think it’s an align 1 store, I don't think so.<u></u><u></u></span></b></p>
<p class="MsoNormal"><span lang="EN-US"><img width="648" height="227" id="gmail-m_-8138766083693493927_x56fe__x7247__x0020_2" src="cid:171c1b439c05b16b22"></span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(102,102,102)">CMD: llc -mattr=+strict-align test.ll<u></u><u></u></span></p>
<p class="MsoNormal"><b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(102,102,102)">If the CPU does not support non-aligned access, The access is divided into four one-byte access.<u></u><u></u></span></b></p>
<p class="MsoNormal"><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(102,102,102)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(102,102,102)"><img width="228" height="118" id="gmail-m_-8138766083693493927_x56fe__x7247__x0020_3" src="cid:171c1b439c0692e333"></span><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(102,102,102)"><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(102,102,102)">CMD: llc -mattr=-strict-align test.ll<u></u><u></u></span></p>
<p class="MsoNormal"><b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(102,102,102)">If the CPU support non-aligned access, It's a normal four-byte access.<u></u><u></u></span></b></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(102,102,102)"><img width="272" height="66" id="gmail-m_-8138766083693493927_x56fe__x7247__x0020_5" src="cid:171c1b439c07745b44"></span><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(102,102,102)"><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(102,102,102)"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(102,102,102)">But gcc always think it’s an aligned access ,and processed him as a four-byte access. I think this is reasonable.<u></u><u></u></span></b></p>
<p class="MsoNormal"><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(102,102,102)">CMD1: arm-none-eabi-gcc -mcpu=cortex-r52 -mthumb  -munaligned-access -O0 -emit-llvm -S test.c -o test.s<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(102,102,102)">CMD2: arm-none-eabi-gcc -mcpu=cortex-r52 -mthumb  -mno-unaligned-access -O0 -emit-llvm -S test.c -o test.s<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><img width="235" height="77" id="gmail-m_-8138766083693493927_x56fe__x7247__x0020_6" src="cid:171c1b439c3855d355"></span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span lang="EN" style="font-size:10pt;font-family:Arial,sans-serif;color:rgb(102,102,102)">Why does LLVM think it's a one-byte-aligned access? I think it makes more sense to access the number of aligned based on the type of the array element
 to which the array pointer points</span><span lang="EN-US"><u></u><u></u></span></b></p>
</div>
</div>

_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>