[PATCH] D75407: [InstSimplify] Constant fold icmp of gep
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 4 10:05:51 PST 2020
nikic updated this revision to Diff 248223.
nikic added a comment.
Rebase and simplify.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D75407/new/
https://reviews.llvm.org/D75407
Files:
lib/Analysis/InstructionSimplify.cpp
test/Transforms/InstSimplify/compare.ll
Index: test/Transforms/InstSimplify/compare.ll
===================================================================
--- test/Transforms/InstSimplify/compare.ll
+++ 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: lib/Analysis/InstructionSimplify.cpp
===================================================================
--- lib/Analysis/InstructionSimplify.cpp
+++ 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.248223.patch
Type: text/x-patch
Size: 1221 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200304/513ba6dd/attachment.bin>
More information about the llvm-commits
mailing list