[InstCombine] fold bitcasts around an extractelement
authorSanjay Patel <spatel@rotateright.com>
Wed, 9 Dec 2015 16:17:20 +0000 (16:17 +0000)
committerSanjay Patel <spatel@rotateright.com>
Wed, 9 Dec 2015 16:17:20 +0000 (16:17 +0000)
commiteb103602da8248367c11249982010b15885f8ae4
tree9df4f3ebe3160dca400d98033774a9d3326e3449
parent13f632f17efc05fca61e9cb188f51a54bfc440ed
[InstCombine] fold bitcasts around an extractelement

Example:
  bitcast (extractelement (bitcast <2 x float> %X to <2 x i32>), 1) to float
    --->
  extractelement <2 x float> %X, i32 1

This is part of fixing PR25543:
https://llvm.org/bugs/show_bug.cgi?id=25543

The next step will be to generalize this fold:
trunc ( lshr ( bitcast X) ) -> extractelement (X)

Ie, I'm hoping to replace the existing transform of:
bitcast ( trunc ( lshr ( bitcast X)))
added by:
http://reviews.llvm.org/rL112232

with 2 less specific transforms to catch the case in the bug report.

Differential Revision: http://reviews.llvm.org/D14879

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255124 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombineCasts.cpp
test/Transforms/InstCombine/bitcast.ll