[InstCombine] Teach SimplifyDemandedVectorElts how to handle ConstantVector select...
authorAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>
Tue, 6 Oct 2015 10:34:53 +0000 (10:34 +0000)
committerAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>
Tue, 6 Oct 2015 10:34:53 +0000 (10:34 +0000)
commitb0c38394ffddb3916be295b22e7629cd58494182
treeca3de73f674fb7734b73aa646a2da22a9e5887b0
parentc06b5e8aab782a8117419c28f7660e062701307c
[InstCombine] Teach SimplifyDemandedVectorElts how to handle ConstantVector select masks with ConstantExpr elements (PR24922)

If the mask of a select instruction is a ConstantVector, method
SimplifyDemandedVectorElts iterates over the mask elements to identify which
values are selected from the select inputs.

Before this patch, method SimplifyDemandedVectorElts always used method
Constant::isNullValue() to check if a value in the mask was zero. Unfortunately
that method always returns false when called on a ConstantExpr.

This patch fixes the problem in SimplifyDemandedVectorElts by adding an explicit
check for ConstantExpr values. Now, if a value in the mask is a ConstantExpr, we
avoid calling isNullValue() on it.

Fixes PR24922.

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

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