[PATCH] D24301: [ConstantFold] Teach how to fold a bitcast of a constant vector with some undef elements.

Andrea Di Biagio via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 7 10:19:48 PDT 2016


andreadb created this revision.
andreadb added reviewers: RKSimon, spatel, majnemer.
andreadb added a subscriber: llvm-commits.

The previous logic didn't always know how to handle bitcasts of integer vectors with some undef elements.

The problem only affected the case where the bitcast vector type had more packed elements than the input vector type.

Example:
  %cast = bitcast <2 x i64> <i64 undef, i64 2> to <4 x i32>

On a little endian target, that bitcast could be folded into the following constant vector:
<2 x i64><i64 undef, i64 undef, i64 2, i64 0>

However, the input vector had some undef elements, and the constant folder didn't know how to handle them.
This patch improves the logic by teaching how to deal with undefs.

Please let me know if okay to commit.
Thanks,
Andrea

https://reviews.llvm.org/D24301

Files:
  lib/Analysis/ConstantFolding.cpp
  test/Transforms/InstCombine/x86-sse4a.ll
  test/Transforms/InstSimplify/bitcast-vector-fold.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24301.70553.patch
Type: text/x-patch
Size: 10534 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160907/94f38607/attachment.bin>


More information about the llvm-commits mailing list