]> granicus.if.org Git - llvm/commit
Merging r247128:
authorDaniel Sanders <daniel.sanders@imgtec.com>
Mon, 14 Sep 2015 10:40:55 +0000 (10:40 +0000)
committerDaniel Sanders <daniel.sanders@imgtec.com>
Mon, 14 Sep 2015 10:40:55 +0000 (10:40 +0000)
commit17611b180b77406671cf0819a452dd128ce7481c
treef1b53e2078a9ea0b1bcc7bac149dfecb90b9ce68
parent9b5d11e278ef32fd453c8050af899837f69e1d99
Merging r247128:
------------------------------------------------------------------------
r247128 | dsanders | 2015-09-09 10:53:20 +0100 (Wed, 09 Sep 2015) | 31 lines

Fix vector splitting for extract_vector_elt and vector elements of <8-bits.

Summary:
One of the vector splitting paths for extract_vector_elt tries to lower:
    define i1 @via_stack_bug(i8 signext %idx) {
      %1 = extractelement <2 x i1> <i1 false, i1 true>, i8 %idx
      ret i1 %1
    }
to:
    define i1 @via_stack_bug(i8 signext %idx) {
      %base = alloca <2 x i1>
      store <2 x i1> <i1 false, i1 true>, <2 x i1>* %base
      %2 = getelementptr <2 x i1>, <2 x i1>* %base, i32 %idx
      %3 = load i1, i1* %2
      ret i1 %3
    }
However, the elements of <2 x i1> are not byte-addressible. The result of this
is that the getelementptr expands to '%base + %idx * (1 / 8)' which simplifies
to '%base + %idx * 0', and then simply '%base' causing all values of %idx to
extract element zero.

This commit fixes this by promoting the vector elements of <8-bits to i8 before
splitting the vector.

This fixes a number of test failures in pocl.

Reviewers: pekka.jaaskelainen

Subscribers: pekka.jaaskelainen, llvm-commits

Differential Revision: http://reviews.llvm.org/D12591
------------------------------------------------------------------------

git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_37@247539 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
test/CodeGen/Mips/llvm-ir/extractelement.ll [new file with mode: 0644]