Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 7801978

Browse files
nagisabrson
authored andcommitted
Backport rL281650
1 parent 16b79d0 commit 7801978

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

lib/Transforms/InstCombine/InstCombineCompares.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ static bool canRewriteGEPAsOffset(Value *Start, Value *Base,
634634
}
635635

636636
if (!isa<IntToPtrInst>(V) && !isa<PtrToIntInst>(V) &&
637-
!isa<GEPOperator>(V) && !isa<PHINode>(V))
637+
!isa<GetElementPtrInst>(V) && !isa<PHINode>(V))
638638
// We've found some value that we can't explore which is different from
639639
// the base. Therefore we can't do this transformation.
640640
return false;

test/Transforms/InstCombine/indexed-gep-compares.ll

+20
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,24 @@ lpad:
167167
; CHECK: ret i32* %[[PTR]]
168168
}
169169

170+
171+
@pr30402 = constant i64 3
172+
define i1 @test7() {
173+
entry:
174+
br label %bb7
175+
176+
bb7: ; preds = %bb10, %entry-block
177+
%phi = phi i64* [ @pr30402, %entry ], [ getelementptr inbounds (i64, i64* @pr30402, i32 1), %bb7 ]
178+
%cmp = icmp eq i64* %phi, getelementptr inbounds (i64, i64* @pr30402, i32 1)
179+
br i1 %cmp, label %bb10, label %bb7
180+
181+
bb10:
182+
ret i1 %cmp
183+
}
184+
; CHECK-LABEL: @test7(
185+
; CHECK: %[[phi:.*]] = phi i64* [ @pr30402, %entry ], [ getelementptr inbounds (i64, i64* @pr30402, i32 1), %bb7 ]
186+
; CHECK: %[[cmp:.*]] = icmp eq i64* %[[phi]], getelementptr inbounds (i64, i64* @pr30402, i32 1)
187+
; CHECK: ret i1 %[[cmp]]
188+
189+
170190
declare i32 @__gxx_personality_v0(...)

0 commit comments

Comments
 (0)