[llvm-bugs] [Bug 45957] New: X86InterleavedAccess introduces misaligned loads

via llvm-bugs llvm-bugs at lists.llvm.org
Sun May 17 08:00:31 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=45957

            Bug ID: 45957
           Summary: X86InterleavedAccess introduces misaligned loads
           Product: libraries
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Keywords: miscompilation
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: nunoplopes at sapo.pt
                CC: craig.topper at gmail.com, juneyoung.lee at sf.snu.ac.kr,
                    llvm-bugs at lists.llvm.org, llvm-dev at redking.me.uk,
                    regehr at cs.utah.edu, spatel+llvm at rotateright.com

See here:
https://github.com/llvm/llvm-project/blob/master/llvm/lib/Target/X86/X86InterleavedAccess.cpp#L219

    Value *NewBasePtr =
        Builder.CreateGEP(VecBaseTy, VecBasePtr, Builder.getInt32(i));
    Instruction *NewLoad =
        Builder.CreateAlignedLoad(VecBaseTy, NewBasePtr, LI->getAlign());

Newly created loads inherit the original load's alignment. This is not correct,
as the original load may have a larger alignment than the GEP done above.

A concrete failure we see is in:
Transforms/InterleavedAccess/X86/interleavedLoad.ll

define <32 x i8> @interleaved_load_vf32_i8_stride3(* %ptr) {
  %wide.vec = load <96 x i8>, * %ptr, align 128
...
}
=>
define <32 x i8> @interleaved_load_vf32_i8_stride3(* %ptr) {
  %1 = bitcast * %ptr to *
  %2 = gep * %1, 16 x i32 0
  %3 = load <16 x i8>, * %2, align 128  ; <-- this is not 128-byte aligned
  %4 = gep * %1, 16 x i32 1
  %5 = load <16 x i8>, * %4, align 128
  %6 = gep * %1, 16 x i32 2
  %7 = load <16 x i8>, * %6, align 128
...
}


Report:
https://web.ist.utl.pt/nuno.lopes/alive2/index.php?hash=72296a443c683892&test=Transforms%2FInterleavedAccess%2FX86%2FinterleavedLoad.ll

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200517/1460762f/attachment.html>


More information about the llvm-bugs mailing list