1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00

When the two operands of an icmp are equal, there are five possible predicates

that would make the icmp true. Fixes PR1637.

llvm-svn: 41740
This commit is contained in:
Nick Lewycky 2007-09-06 01:10:22 +00:00
parent 15c07fb194
commit 2f66503c0a
2 changed files with 13 additions and 1 deletions

View File

@ -4563,7 +4563,9 @@ Instruction *InstCombiner::FoldGEPICmp(User *GEPLHS, Value *RHS,
if (NumDifferences == 0) // SAME GEP?
return ReplaceInstUsesWith(I, // No comparison is needed here.
ConstantInt::get(Type::Int1Ty,
Cond == ICmpInst::ICMP_EQ));
Cond == ICmpInst::ICMP_EQ ||
Cond == ICmpInst::ICMP_ULE || Cond == ICmpInst::ICMP_UGE ||
Cond == ICmpInst::ICMP_SLE || Cond == ICmpInst::ICMP_SGE));
else if (NumDifferences == 1) {
Value *LHSV = GEPLHS->getOperand(DiffOperand);
Value *RHSV = GEPRHS->getOperand(DiffOperand);

View File

@ -0,0 +1,10 @@
; RUN: llvm-as < %s | opt -instcombine | llvm-dis | grep {ret i1 true}
; PR1637
define i1 @f(i8* %arr) {
%X = getelementptr i8* %arr, i32 1
%Y = getelementptr i8* %arr, i32 1
%test = icmp uge i8* %X, %Y
ret i1 %test
}