[PATCH] D22747: [InstCombine] try to fold (select C, (sext A), B) into logical ops

Nicolai Hähnle via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 25 03:30:44 PDT 2016


nhaehnle created this revision.
nhaehnle added reviewers: majnemer, spatel, tstellarAMD.
nhaehnle added a subscriber: llvm-commits.

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.

https://reviews.llvm.org/D22747

Files:
  lib/Transforms/InstCombine/InstCombineSelect.cpp
  test/Transforms/InstCombine/select-bitext.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22747.65321.patch
Type: text/x-patch
Size: 7144 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160725/371acfa0/attachment.bin>


More information about the llvm-commits mailing list