[all-commits] [llvm/llvm-project] 682f0b: [InstCombine] use select-of-constants with set/cle...
RotateRight via All-commits
all-commits at lists.llvm.org
Sun May 3 06:49:52 PDT 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: 682f0b366be266b9473507f12be21021e3e4912f
https://github.com/llvm/llvm-project/commit/682f0b366be266b9473507f12be21021e3e4912f
Author: Sanjay Patel <spatel at rotateright.com>
Date: 2020-05-03 (Sun, 03 May 2020)
Changed paths:
M llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
M llvm/test/Transforms/InstCombine/cast.ll
M llvm/test/Transforms/InstCombine/select-with-bitwise-ops.ll
Log Message:
-----------
[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
More information about the All-commits
mailing list