[PATCH] D75407: [InstSimplify] Constant fold icmp of gep
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 4 14:40:27 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc6ff3c9bad88: [InstSimplify] Constant fold icmp of gep (authored by nikic).
Herald added a subscriber: hiraditya.
Changed prior to commit:
https://reviews.llvm.org/D75407?vs=248223&id=248320#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D75407/new/
https://reviews.llvm.org/D75407
Files:
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/test/Transforms/InstSimplify/compare.ll
Index: llvm/test/Transforms/InstSimplify/compare.ll
===================================================================
--- llvm/test/Transforms/InstSimplify/compare.ll
+++ llvm/test/Transforms/InstSimplify/compare.ll
@@ -301,7 +301,7 @@
define i1 @gep_same_base_constant_indices(i8* %a) {
; CHECK-LABEL: @gep_same_base_constant_indices(
-; CHECK-NEXT: ret i1 icmp slt (i8* getelementptr (i8, i8* null, i64 1), i8* getelementptr (i8, i8* null, i64 10))
+; CHECK-NEXT: ret i1 true
;
%arrayidx1 = getelementptr inbounds i8, i8* %a, i64 1
%arrayidx2 = getelementptr inbounds i8, i8* %a, i64 10
Index: llvm/lib/Analysis/InstructionSimplify.cpp
===================================================================
--- llvm/lib/Analysis/InstructionSimplify.cpp
+++ llvm/lib/Analysis/InstructionSimplify.cpp
@@ -3481,7 +3481,8 @@
SmallVector<Value *, 4> IndicesRHS(GRHS->idx_begin(), GRHS->idx_end());
Constant *NewRHS = ConstantExpr::getGetElementPtr(
GLHS->getSourceElementType(), Null, IndicesRHS);
- return ConstantExpr::getICmp(Pred, NewLHS, NewRHS);
+ Constant *NewICmp = ConstantExpr::getICmp(Pred, NewLHS, NewRHS);
+ return ConstantFoldConstant(NewICmp, Q.DL);
}
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75407.248320.patch
Type: text/x-patch
Size: 1251 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200304/bc23e788/attachment.bin>
More information about the llvm-commits
mailing list