[llvm-bugs] [Bug 50382] New: extractelement lowering and LangRef don't match

via llvm-bugs llvm-bugs at lists.llvm.org
Tue May 18 02:29:00 PDT 2021


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

            Bug ID: 50382
           Summary: extractelement lowering and LangRef don't match
           Product: libraries
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Target Description Classes
          Assignee: unassignedbugs at nondot.org
          Reporter: nunoplopes at sapo.pt
                CC: florian_hahn at apple.com, fwage73 at gmail.com,
                    llvm-bugs at lists.llvm.org, llvm-dev at redking.me.uk,
                    regehr at cs.utah.edu, spatel+llvm at rotateright.com

LangRef says that extractelement with an OOB index yields poison.
However, it seems all targets lower an OOB index operation to a crash:
https://gcc.godbolt.org/z/9jxd9esnE
This lowering would correspond to an UB semantics rather than poison on OOB.

define i32 @f(<4 x i32>* %x, i64 %idx) {
  %lv = load <4 x i32>, <4 x i32>* %x
  %r = extractelement <4 x i32> %lv, i64 %idx
  ret i32 %r
}

x86:
    mov     eax, dword ptr [rdi + 4*rsi]
    ret


We have 2 options:
 1) Change LangRef so that extractelement gives UB on OOB index
 2) Mask the index when lowering (unless it's known to be inbounds)

I don't know what the implications of 1) are. i.e., which front-ends produce it
and from which code and which guarantees those front-ends need.

-- 
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/20210518/a9e84cc2/attachment.html>


More information about the llvm-bugs mailing list