Skip to content
This repository has been archived by the owner on Oct 31, 2022. It is now read-only.

Commit

Permalink
Apply an InstCombine backport via rust-lang/llvm#51
Browse files Browse the repository at this point in the history
  • Loading branch information
cuviper committed Oct 15, 2016
1 parent 262978a commit 307be8a
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
55 changes: 55 additions & 0 deletions 0001-Backport-rL281650.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
From 7801978ec1f3637fcda1b564048ebc732bf586af Mon Sep 17 00:00:00 2001
From: Simonas Kazlauskas <[email protected]>
Date: Fri, 16 Sep 2016 00:32:20 +0300
Subject: [PATCH] Backport rL281650

---
lib/Transforms/InstCombine/InstCombineCompares.cpp | 2 +-
test/Transforms/InstCombine/indexed-gep-compares.ll | 20 ++++++++++++++++++++
2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/lib/Transforms/InstCombine/InstCombineCompares.cpp b/lib/Transforms/InstCombine/InstCombineCompares.cpp
index bfd73f4bbac5..961497fe3c2d 100644
--- a/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -634,7 +634,7 @@ static bool canRewriteGEPAsOffset(Value *Start, Value *Base,
}

if (!isa<IntToPtrInst>(V) && !isa<PtrToIntInst>(V) &&
- !isa<GEPOperator>(V) && !isa<PHINode>(V))
+ !isa<GetElementPtrInst>(V) && !isa<PHINode>(V))
// We've found some value that we can't explore which is different from
// the base. Therefore we can't do this transformation.
return false;
diff --git a/test/Transforms/InstCombine/indexed-gep-compares.ll b/test/Transforms/InstCombine/indexed-gep-compares.ll
index 495881549e25..64dff2712976 100644
--- a/test/Transforms/InstCombine/indexed-gep-compares.ll
+++ b/test/Transforms/InstCombine/indexed-gep-compares.ll
@@ -167,4 +167,24 @@ lpad:
; CHECK: ret i32* %[[PTR]]
}

+
+@pr30402 = constant i64 3
+define i1 @test7() {
+entry:
+ br label %bb7
+
+bb7: ; preds = %bb10, %entry-block
+ %phi = phi i64* [ @pr30402, %entry ], [ getelementptr inbounds (i64, i64* @pr30402, i32 1), %bb7 ]
+ %cmp = icmp eq i64* %phi, getelementptr inbounds (i64, i64* @pr30402, i32 1)
+ br i1 %cmp, label %bb10, label %bb7
+
+bb10:
+ ret i1 %cmp
+}
+; CHECK-LABEL: @test7(
+; CHECK: %[[phi:.*]] = phi i64* [ @pr30402, %entry ], [ getelementptr inbounds (i64, i64* @pr30402, i32 1), %bb7 ]
+; CHECK: %[[cmp:.*]] = icmp eq i64* %[[phi]], getelementptr inbounds (i64, i64* @pr30402, i32 1)
+; CHECK: ret i1 %[[cmp]]
+
+
declare i32 @__gxx_personality_v0(...)
--
2.7.4

7 changes: 6 additions & 1 deletion llvm.spec
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

Name: llvm
Version: 3.9.0
Release: 1%{?dist}
Release: 2%{?dist}
Summary: The Low Level Virtual Machine

License: NCSA
Expand All @@ -23,6 +23,7 @@ Patch1: 0001-This-code-block-breaks-the-docs-build-http-lab.llvm..patch
Patch2: 0001-fix-docs-2.patch
Patch3: 0001-fix-docs-3.patch
Patch4: 0001-docs-fix-cmake-code-block-warning.patch
Patch5: 0001-Backport-rL281650.patch

BuildRequires: cmake
BuildRequires: zlib-devel
Expand Down Expand Up @@ -79,6 +80,7 @@ Static libraries for the LLVM compiler infrastructure.
%patch2 -p1 -b .docs2
%patch3 -p1 -b .docs3
%patch4 -p1 -b .docs4
%patch5 -p1 -b .rust1

%build
mkdir -p _build
Expand Down Expand Up @@ -194,6 +196,9 @@ make check-all || :
%{_libdir}/*.a

%changelog
* Sat Oct 15 2016 Josh Stone <[email protected]> - 3.9.0-2
- Apply an InstCombine backport via rust-lang/llvm#51

* Wed Sep 07 2016 Dave Airlie <[email protected]> - 3.9.0-1
- llvm 3.9.0
- upstream moved where cmake files are packaged.
Expand Down

0 comments on commit 307be8a

Please sign in to comment.