llvm-project/llvm/test/Transforms/ConstProp
Nikita Popov 79c994d976 [ConstantFolding] Handle leading zero-size elements in load folding
Struct types may have leading zero-size elements like [0 x i32], in
which case the "real" element at offset 0 will not necessarily coincide
with the 0th element of the aggregate. ConstantFoldLoadThroughBitcast()
wants to drill down the element at offset 0, but currently always picks
the 0th aggregate element to do so. This patch changes the code to find
the first non-zero-size element instead, for the struct case.

The motivation behind this change is https://github.com/rust-lang/rust/issues/48627.
Rust is fond of emitting [0 x iN] separators between struct elements to
enforce alignment, which prevents constant folding in this particular case.

The additional tests with [4294967295 x [0 x i32]] check that we don't
end up unnecessarily looping over a large number of zero-size elements
of a zero-size array.

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

llvm-svn: 348895
2018-12-11 20:29:16 +00:00
..
2002-05-03-DivideByZeroException.ll
2002-05-03-NotOperator.ll
2002-09-03-SetCC-Bools.ll
2003-05-12-DivideError.ll
2005-01-28-SetCCGEP.ll
2006-11-30-vector-cast.ll
2006-12-01-TruncBoolBug.ll
2006-12-01-bool-casts.ll
2007-02-05-BitCast.ll
2007-02-23-sdiv.ll
2007-11-23-cttz.ll
2008-07-07-VectorCompare.ll
2009-06-20-constexpr-zero-lhs.ll
2009-09-01-GEP-Crash.ll
InsertElement.ll
avx512.ll [X86] Add constant folding for AVX512 versions of scalar floating point to integer conversion intrinsics. 2018-08-12 22:09:54 +00:00
basictest.ll
bitcast.ll
bswap.ll
calls-math-finite.ll Disable calls to *_finite and other glibc-only functions on Musl. 2018-11-06 18:23:32 +00:00
calls.ll
cast.ll Make uitofp and sitofp defined on overflow. 2018-06-14 22:58:48 +00:00
constant-expr.ll
convert-from-fp16.ll
div-zero.ll
extractvalue.ll
float-to-ptr-cast.ll
insertvalue.ll
loads.ll [ConstantFolding] Handle leading zero-size elements in load folding 2018-12-11 20:29:16 +00:00
logicaltest.ll
overflow-ops.ll
phi.ll
remtest.ll
shift.ll
sse.ll
trunc_vec.ll