OSDN Git Service

[InstCombine] try to fold (select C, (sext A), B) into logical ops
authorNicolai Haehnle <nhaehnle@gmail.com>
Fri, 5 Aug 2016 08:22:29 +0000 (08:22 +0000)
committerNicolai Haehnle <nhaehnle@gmail.com>
Fri, 5 Aug 2016 08:22:29 +0000 (08:22 +0000)
commitfd14e4374d39167bdb5702504f064c775c9f363d
tree74f585af0a80415f11f53c8fa2dc65a894cefc68
parent784afcbf370b403c7a570e8e785975bd06c4a281
[InstCombine] try to fold (select C, (sext A), B) into logical ops

Summary:
Turn (select C, (sext A), B) into (sext (select C, A, B')) when A is i1 and
B is a compatible constant, also for zext instead of sext. This will then be
further folded into logical operations.

The transformation would be valid for non-i1 types as well, but other parts of
InstCombine prefer to have sext from non-i1 as an operand of select.

Motivated by the shader compiler frontend in Mesa for AMDGPU, which emits i32
for boolean operations. With this change, the boolean logic is fully
recovered.

Reviewers: majnemer, spatel, tstellarAMD

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277801 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombineSelect.cpp
lib/Transforms/InstCombine/InstructionCombining.cpp
test/Transforms/InstCombine/select-bitext.ll
test/Transforms/InstCombine/vector-casts.ll