[llvm-branch-commits] [llvm-branch] r293669 - Merging r293629:

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Jan 31 10:33:01 PST 2017


Author: hans
Date: Tue Jan 31 12:33:00 2017
New Revision: 293669

URL: http://llvm.org/viewvc/llvm-project?rev=293669&view=rev
Log:
Merging r293629:
------------------------------------------------------------------------
r293629 | sbaranga | 2017-01-31 06:04:15 -0800 (Tue, 31 Jan 2017) | 15 lines

[InstCombine] Make sure that LHS and RHS have the same type in
transformToIndexedCompare

If they don't have the same type, the size of the constant
index would need to be adjusted (and this wouldn't be always
possible).

Alternatively we could try the analysis with the initial
RHS value, which would guarantee that the two sides have
the same type. However it is unlikely that in practice this
would pass our transformation requirements.

Fixes PR31808 (https://llvm.org/bugs/show_bug.cgi?id=31808).


------------------------------------------------------------------------

Modified:
    llvm/branches/release_40/   (props changed)
    llvm/branches/release_40/lib/Transforms/InstCombine/InstCombineCompares.cpp
    llvm/branches/release_40/test/Transforms/InstCombine/indexed-gep-compares.ll

Propchange: llvm/branches/release_40/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 31 12:33:00 2017
@@ -1,3 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,291858-291859,291863,291875,291909,291918,291966,291968,291979,292117,292133,292242,292254-292255,292280,292323,292444,292467,292516,292583,292624-292625,292641,292651,292667,292711-292713,292758,293021,293025,293259,293291,293293,293417,293522
+/llvm/trunk:155241,291858-291859,291863,291875,291909,291918,291966,291968,291979,292117,292133,292242,292254-292255,292280,292323,292444,292467,292516,292583,292624-292625,292641,292651,292667,292711-292713,292758,293021,293025,293259,293291,293293,293417,293522,293629

Modified: llvm/branches/release_40/lib/Transforms/InstCombine/InstCombineCompares.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=293669&r1=293668&r2=293669&view=diff
==============================================================================
--- llvm/branches/release_40/lib/Transforms/InstCombine/InstCombineCompares.cpp (original)
+++ llvm/branches/release_40/lib/Transforms/InstCombine/InstCombineCompares.cpp Tue Jan 31 12:33:00 2017
@@ -884,6 +884,10 @@ static Instruction *transformToIndexedCo
   if (!GEPLHS->hasAllConstantIndices())
     return nullptr;
 
+  // Make sure the pointers have the same type.
+  if (GEPLHS->getType() != RHS->getType())
+    return nullptr;
+
   Value *PtrBase, *Index;
   std::tie(PtrBase, Index) = getAsConstantIndexedAddress(GEPLHS, DL);
 

Modified: llvm/branches/release_40/test/Transforms/InstCombine/indexed-gep-compares.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/test/Transforms/InstCombine/indexed-gep-compares.ll?rev=293669&r1=293668&r2=293669&view=diff
==============================================================================
--- llvm/branches/release_40/test/Transforms/InstCombine/indexed-gep-compares.ll (original)
+++ llvm/branches/release_40/test/Transforms/InstCombine/indexed-gep-compares.ll Tue Jan 31 12:33:00 2017
@@ -188,3 +188,20 @@ bb10:
 
 
 declare i32 @__gxx_personality_v0(...)
+
+define i1 @test8(i64* %in, i64 %offset) {
+entry:
+
+ %ld = load i64, i64* %in, align 8
+ %casti8 = inttoptr i64 %ld to i8*
+ %gepi8 = getelementptr inbounds i8, i8* %casti8, i64 %offset
+ %cast = bitcast i8* %gepi8 to i32**
+ %ptrcast = inttoptr i64 %ld to i32**
+ %gepi32 = getelementptr inbounds i32*, i32** %ptrcast, i64 1
+ %cmp = icmp eq i32** %gepi32, %cast
+ ret i1 %cmp
+
+
+; CHECK-LABEL: @test8(
+; CHECK-NOT: icmp eq i32 %{{[0-9A-Za-z.]+}}, 1
+}




More information about the llvm-branch-commits mailing list