[all-commits] [llvm/llvm-project] 2eb7a8: [InstCombine] Relax the one-use constraints for `i...
Yingwei Zheng via All-commits
all-commits at lists.llvm.org
Sun Jan 7 04:16:29 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 2eb7a82af3b66f9448f9d2843b438fa8ec4ff53f
https://github.com/llvm/llvm-project/commit/2eb7a82af3b66f9448f9d2843b438fa8ec4ff53f
Author: Yingwei Zheng <dtcxzyw2333 at gmail.com>
Date: 2024-01-07 (Sun, 07 Jan 2024)
Changed paths:
M llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
M llvm/test/Transforms/InstCombine/icmp.ll
Log Message:
-----------
[InstCombine] Relax the one-use constraints for `icmp pred (binop X, Z), (binop Y, Z)` (#76384)
This patch relaxes the one-use constraints for `icmp pred (binop X, Z),
(binop Y, Z)`. It will enable more optimizations with pointer
arithmetic.
One example in `boost::match_results::set_size`:
```
declare void @use(i64)
define i1 @src(ptr %a1, ptr %a2, ptr %add.ptr.i66, i64 %sub.ptr.rhs.cast.i) {
%sub.ptr.lhs.cast.i = ptrtoint ptr %a1 to i64
%sub.ptr.rhs.cast.i = ptrtoint ptr %a2 to i64
%sub.ptr.sub.i = sub i64 %sub.ptr.lhs.cast.i, %sub.ptr.rhs.cast.i
%sub.ptr.div.i = sdiv exact i64 %sub.ptr.sub.i, 24
call void @use(i64 %sub.ptr.div.i)
%sub.ptr.lhs.cast.i.i = ptrtoint ptr %add.ptr.i66 to i64
%sub.ptr.sub.i.i = sub i64 %sub.ptr.lhs.cast.i.i, %sub.ptr.rhs.cast.i
%sub.ptr.div.i.i = sdiv exact i64 %sub.ptr.sub.i.i, 24
%cmp.i.not.i.i = icmp eq i64 %sub.ptr.div.i.i, %sub.ptr.div.i
ret i1 %cmp.i.not.i.i
}
define i1 @tgt(ptr %a1, ptr %a2, ptr %add.ptr.i66, i64 %sub.ptr.rhs.cast.i) {
%sub.ptr.lhs.cast.i = ptrtoint ptr %a1 to i64
%sub.ptr.rhs.cast.i = ptrtoint ptr %a2 to i64
%sub.ptr.sub.i = sub i64 %sub.ptr.lhs.cast.i, %sub.ptr.rhs.cast.i
%sub.ptr.div.i = sdiv exact i64 %sub.ptr.sub.i, 24
call void @use(i64 %sub.ptr.div.i)
%cmp.i.not.i.i = icmp eq i64 %sub.ptr.sub.i.i, %sub.ptr.sub.i
ret i1 %cmp.i.not.i.i
}
```
More information about the All-commits
mailing list