[llvm] [InstCombine] Extend ADD+GEP->GEP+GEP combine to disjoint or. (PR #76981)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 4 12:16:54 PST 2024
dtcxzyw wrote:
Yeah, I see some similar changes in `bench/ocio/optimized/ImagePacking.cpp.ll`:
```
diff --git a/bench/ocio/optimized/ImagePacking.cpp.ll b/bench/ocio/optimized/ImagePacking.cpp.ll
index 490d6aec..b632e889 100644
--- a/bench/ocio/optimized/ImagePacking.cpp.ll
+++ b/bench/ocio/optimized/ImagePacking.cpp.ll
@@ -116,12 +116,15 @@ while.body.preheader: ; preds = %if.end7
%add.ptr = getelementptr inbounds i8, ptr %9, i64 %mul8
%add.ptr14 = getelementptr inbounds i8, ptr %add.ptr, i64 %mul13
%wide.trip.count = zext nneg i32 %outputBufferSize to i64
- %spec.select62 = select i1 %tobool.not, ptr null, ptr %add.ptr24
+ %spec.select66 = select i1 %tobool.not, ptr null, ptr %add.ptr24
+ %invariant.gep = getelementptr i8, ptr %inBitDepthBuffer, i64 1
+ %invariant.gep62 = getelementptr i8, ptr %inBitDepthBuffer, i64 2
+ %invariant.gep64 = getelementptr i8, ptr %inBitDepthBuffer, i64 3
br label %while.body
while.body: ; preds = %while.body.preheader, %cond.end
%indvars.iv = phi i64 [ %indvars.iv.next, %cond.end ], [ 0, %while.body.preheader ]
- %aPtr.154 = phi ptr [ %spec.select, %cond.end ], [ %spec.select62, %while.body.preheader ]
+ %aPtr.154 = phi ptr [ %spec.select, %cond.end ], [ %spec.select66, %while.body.preheader ]
%bPtr.053 = phi ptr [ %add.ptr44, %cond.end ], [ %add.ptr18, %while.body.preheader ]
%gPtr.052 = phi ptr [ %add.ptr43, %cond.end ], [ %add.ptr16, %while.body.preheader ]
%rPtr.051 = phi ptr [ %add.ptr42, %cond.end ], [ %add.ptr14, %while.body.preheader ]
@@ -130,25 +133,22 @@ while.body: ; preds = %while.body.preheade
%arrayidx = getelementptr inbounds i8, ptr %inBitDepthBuffer, i64 %11
store i8 %10, ptr %arrayidx, align 1
%12 = load i8, ptr %gPtr.052, align 1
- %13 = or disjoint i64 %11, 1
- %arrayidx31 = getelementptr inbounds i8, ptr %inBitDepthBuffer, i64 %13
- store i8 %12, ptr %arrayidx31, align 1
- %14 = load i8, ptr %bPtr.053, align 1
- %15 = or disjoint i64 %11, 2
- %arrayidx35 = getelementptr inbounds i8, ptr %inBitDepthBuffer, i64 %15
- store i8 %14, ptr %arrayidx35, align 1
+ %gep = getelementptr i8, ptr %invariant.gep, i64 %11
+ store i8 %12, ptr %gep, align 1
+ %13 = load i8, ptr %bPtr.053, align 1
+ %gep63 = getelementptr i8, ptr %invariant.gep62, i64 %11
+ store i8 %13, ptr %gep63, align 1
%tobool36.not = icmp eq ptr %aPtr.154, null
br i1 %tobool36.not, label %cond.end, label %cond.true
cond.true: ; preds = %while.body
- %16 = load i8, ptr %aPtr.154, align 1
+ %14 = load i8, ptr %aPtr.154, align 1
br label %cond.end
cond.end: ; preds = %while.body, %cond.true
- %cond = phi i8 [ %16, %cond.true ], [ 0, %while.body ]
- %17 = or disjoint i64 %11, 3
- %arrayidx40 = getelementptr inbounds i8, ptr %inBitDepthBuffer, i64 %17
- store i8 %cond, ptr %arrayidx40, align 1
+ %cond = phi i8 [ %14, %cond.true ], [ 0, %while.body ]
+ %gep65 = getelementptr i8, ptr %invariant.gep64, i64 %11
+ store i8 %cond, ptr %gep65, align 1
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
%add.ptr42 = getelementptr inbounds i8, ptr %rPtr.051, i64 %4
%add.ptr43 = getelementptr inbounds i8, ptr %gPtr.052, i64 %4
```
@nikic Did you mean it will cause register allocator to introduce more spills?
https://github.com/llvm/llvm-project/pull/76981
More information about the llvm-commits
mailing list