diff options
author | Sanjay Patel <spatel@rotateright.com> | 2020-07-20 15:49:01 -0400 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2020-07-20 16:18:11 -0400 |
commit | 750f4c591d6c3a62887250783e2a63af0daaa630 (patch) | |
tree | 3ab53d9acaf8227e698994cd7ff0ff6b0f845bba /llvm/lib/ExecutionEngine/SectionMemoryManager.cpp | |
parent | 92ec0c5da69e47c449499d9414b8f5ac8481abdb (diff) | |
download | llvm-750f4c591d6c3a62887250783e2a63af0daaa630.zip llvm-750f4c591d6c3a62887250783e2a63af0daaa630.tar.gz llvm-750f4c591d6c3a62887250783e2a63af0daaa630.tar.bz2 |
[InstCombine] allow peeking through zext of shift amount to match rotate idioms (PR45701)
We might want to also allow trunc of the shift amount, but that seems less likely?
define i32 @src(i32 %x, i1 %y) {
%0:
%rem = and i1 %y, 1
%cmp = icmp eq i1 %rem, 0
%sh_prom = zext i1 %rem to i32
%sub = sub nsw nuw i1 0, %rem
%sh_prom1 = zext i1 %sub to i32
%shr = lshr i32 %x, %sh_prom1
%shl = shl i32 %x, %sh_prom
%or = or i32 %shl, %shr
%r = select i1 %cmp, i32 %x, i32 %or
ret i32 %r
}
=>
define i32 @tgt(i32 %x, i1 %y) {
%0:
%t = zext i1 %y to i32
%r = fshl i32 %x, i32 %x, i32 %t
ret i32 %r
}
Transformation seems to be correct!
https://alive2.llvm.org/ce/z/xgMvE3
http://bugs.llvm.org/PR45701
Diffstat (limited to 'llvm/lib/ExecutionEngine/SectionMemoryManager.cpp')
0 files changed, 0 insertions, 0 deletions