diff options
author | Sanjay Patel <spatel@rotateright.com> | 2020-05-03 09:43:49 -0400 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2020-05-03 09:44:43 -0400 |
commit | 682f0b366be266b9473507f12be21021e3e4912f (patch) | |
tree | eb92ae60a0133e03ceb8a2d18e92947e58761759 /llvm/lib/Support/Path.cpp | |
parent | af28c74e8fc5739b419e61ba91d5a052d6c4cd2c (diff) | |
download | llvm-682f0b366be266b9473507f12be21021e3e4912f.zip llvm-682f0b366be266b9473507f12be21021e3e4912f.tar.gz llvm-682f0b366be266b9473507f12be21021e3e4912f.tar.bz2 |
[InstCombine] use select-of-constants with set/clear bit mask patterns
Cond ? (X & ~C) : (X | C) --> (X & ~C) | (Cond ? 0 : C)
Cond ? (X | C) : (X & ~C) --> (X & ~C) | (Cond ? C : 0)
The select-of-constants form results in better codegen.
There's an existing test diff that shows a transform that
results in an extra IR instruction, but that's an existing
problem.
This is motivated by code seen in LLVM itself - see PR37581:
https://bugs.llvm.org/show_bug.cgi?id=37581
define i8 @src(i8 %x, i8 %C, i1 %b) {
%notC = xor i8 %C, -1
%and = and i8 %x, %notC
%or = or i8 %x, %C
%cond = select i1 %b, i8 %or, i8 %and
ret i8 %cond
}
define i8 @tgt(i8 %x, i8 %C, i1 %b) {
%notC = xor i8 %C, -1
%and = and i8 %x, %notC
%mul = select i1 %b, i8 %C, i8 0
%or = or i8 %mul, %and
ret i8 %or
}
http://volta.cs.utah.edu:8080/z/Vt2WVm
Differential Revision: https://reviews.llvm.org/D78880
Diffstat (limited to 'llvm/lib/Support/Path.cpp')
0 files changed, 0 insertions, 0 deletions