[llvm] [InstCombine] Extend `foldICmpAddConstant` to disjoint `or`. (PR #75899)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 20 01:55:21 PST 2023
dtcxzyw wrote:
> > @mgudim Could you please have a look at [dtcxzyw/llvm-opt-benchmark#10](https://github.com/dtcxzyw/llvm-opt-benchmark/pull/10)? Our CI found that this patch introduced some unnecessary `and %size, ~signmask` patterns before calling `operator new(size_t)`. Some file changes:
>
> @dtcxzyw Sure, I'll take a look. But I didn't understand what file exactly the regressions are at. Can you paste the IR before and after the transformation. Preferably the smallest function which shows the regression.
One example:
```
diff --git a/bench/proxygen/optimized/HTTP2PriorityQueue.cpp.ll b/bench/proxygen/optimized/HTTP2PriorityQueue.cpp.ll
index 54ccb32b..9d7fe815 100644
--- a/bench/proxygen/optimized/HTTP2PriorityQueue.cpp.ll
+++ b/bench/proxygen/optimized/HTTP2PriorityQueue.cpp.ll
@@ -7152,7 +7152,7 @@ entry:
%mul3.i31 = shl i64 %newChunkCount, 8
%retval.0.i32 = select i1 %cmp.i28, i64 %add.i30, i64 %mul3.i31
store i64 %retval.0.i32, ptr %newAllocSize, align 8
- %cmp.i.i.i.i.i = icmp slt i64 %retval.0.i32, 0
+ %cmp.i.i.i.i.i = icmp slt i64 %retval.0.i32, -15
br i1 %cmp.i.i.i.i.i, label %if.then.i.i.i.i.i, label %_ZN5folly3f146detail10BasePolicyImPN8proxygen18HTTP2PriorityQueue4NodeEvvvSt4pairIKmS6_EE12beforeRehashEmmmmRPh.exit
if.then.i.i.i.i.i: ; preds = %entry
@@ -7160,7 +7160,8 @@ if.then.i.i.i.i.i: ; preds = %entry
unreachable
_ZN5folly3f146detail10BasePolicyImPN8proxygen18HTTP2PriorityQueue4NodeEvvvSt4pairIKmS6_EE12beforeRehashEmmmmRPh.exit: ; preds = %entry
- %call5.i.i2.i.i1.i = tail call noalias noundef nonnull ptr @_Znwm(i64 noundef %retval.0.i32) #30
+ %div1.i.i.i = and i64 %retval.0.i32, 9223372036854775792
+ %call5.i.i2.i.i1.i = tail call noalias noundef nonnull ptr @_Znwm(i64 noundef %div1.i.i.i) #30
store ptr %call5.i.i2.i.i1.i, ptr %rawAllocation, align 8
store i8 0, ptr %undoState, align 1
%cmp5.not.i = icmp ne i64 %newChunkCount, 0
```
I will post a reduced test case later :)
https://github.com/llvm/llvm-project/pull/75899
More information about the llvm-commits
mailing list