OSDN Git Service

[LoopVectorize] Refine hasIrregularType predicate
authorLemonBoy <thatlemon@gmail.com>
Wed, 17 Mar 2021 15:59:55 +0000 (16:59 +0100)
committerTom Stellard <tstellar@redhat.com>
Wed, 31 Mar 2021 19:10:37 +0000 (12:10 -0700)
commit31001be371e8f2c74470e727e54503fb2aabec8b
tree93ea8be722a9712ea312b2f9a9c77749193a27cb
parent9ae9ab1ca34384e07b751c16645e22a0b953b08b
[LoopVectorize] Refine hasIrregularType predicate

The `hasIrregularType` predicate checks whether an array of N values of type Ty is "bitcast-compatible" with a <N x Ty> vector.
The previous check returned invalid results in some cases where there's some padding between the array elements: eg. a 4-element array of u7 values is considered as compatible with <4 x u7>, even though the vector is only loading/storing 28 bits instead of 32.

The problem causes LLVM to generate incorrect code for some targets: for AArch64 the vector loads/stores are lowered in terms of ubfx/bfi, effectively losing the top (N * padding bits).

Reviewed By: lebedev.ri

Differential Revision: https://reviews.llvm.org/D97465

(cherry picked from commit 4f024938e4c932feba4d28573ec4522106f8d879)
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Transforms/LoopVectorize/irregular_type.ll [new file with mode: 0644]