This is an archive of the discontinued LLVM Phabricator instance.

[LSV] Skip all non-byte sizes, not only less than eight bits
ClosedPublic

Authored by bjope on Oct 25 2017, 9:25 AM.

Details

Summary

The code comments indicate that no effort has been spent on
handling load/stores when the size isn't a multiple of the
byte size correctly. However, the code only avoided types
smaller than 8 bits. So for example a load of an i28 could
still be considered as a candidate for vectorization.

This patch adjusts the code to behave according to the code
comment.

The test case used to hit the following assert when
trying to use "cast" an i32 to i28 using CreateBitOrPointerCast:

opt: ../lib/IR/Instructions.cpp:2565: Assertion `castIsValid(op, S, Ty) && "Invalid cast!"' failed.
#0 PrintStackTraceSignalHandler(void*)
#1 SignalHandler(int)
#2 restore_rt
#3
GI_raise
#4 GI_abort
#5
GI___assert_fail
#6 llvm::CastInst::Create(llvm::Instruction::CastOps, llvm::Value*, llvm::Type*, llvm::Twine const&, llvm::Instruction*)
#7 llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>::CreateBitOrPointerCast(llvm::Value*, llvm::Type*, llvm::Twine const&)
#8 (anonymous namespace)::Vectorizer::vectorizeLoadChain(llvm::ArrayRef<llvm::Instruction*>, llvm::SmallPtrSet<llvm::Instruction*, 16u>*)

Diff Detail

Repository
rL LLVM

Event Timeline

bjope created this revision.Oct 25 2017, 9:25 AM
arsenm accepted this revision.Oct 25 2017, 5:27 PM

LGTM

include/llvm/IR/DataLayout.h
382–385 ↗(On Diff #120270)

This should probably be a separate patch

This revision is now accepted and ready to land.Oct 25 2017, 5:27 PM
bjope added inline comments.Oct 26 2017, 6:42 AM
include/llvm/IR/DataLayout.h
382–385 ↗(On Diff #120270)

Ok, I'll skip doing the refactoring in this patch (even though my hidden agenda was to move the byte size dependency to DataLayout, enhancing readability and at the same time making it easier for out-of-tree targets with different byte sizes to simply patch DataLayout).

This revision was automatically updated to reflect the committed changes.