llvm.org GIT mirror llvm / d1ec989
When comparing constants, consider a less wide constant to be "less complex" than a wider one, before trying to compare their contents which will crash if their sizes are different. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74792 91177308-0d34-0410-b5e6-96231b3b80d8 Nick Lewycky 11 years ago
2 changed file(s) with 18 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
494494 // Compare constant values.
495495 if (const SCEVConstant *LC = dyn_cast(LHS)) {
496496 const SCEVConstant *RC = cast(RHS);
497 if (LC->getValue()->getBitWidth() != RC->getValue()->getBitWidth())
498 return LC->getValue()->getBitWidth() < RC->getValue()->getBitWidth();
497499 return LC->getValue()->getValue().ult(RC->getValue()->getValue());
498500 }
499501
0 ; RUN: llvm-as < %s | opt -analyze -scalar-evolution
1 ; PR4501
2
3 define void @test() {
4 entry:
5 %0 = load i16* undef, align 1
6 %1 = lshr i16 %0, 8
7 %2 = and i16 %1, 3
8 %3 = zext i16 %2 to i32
9 %4 = load i8* undef, align 1
10 %5 = lshr i8 %4, 4
11 %6 = and i8 %5, 1
12 %7 = zext i8 %6 to i32
13 %t1 = add i32 %3, %7
14 ret void
15 }