llvm.org GIT mirror llvm / 12f6308
Fix icmp lowering Summary: During icmp lowering it can happen that a constant value can be larger than expected (see the code around the change). APInt::getMinSignedBits() must be checked again as the shift before can change the constant sign to positive. I'm not sure it is the best fix possible though. Test Plan: Regression test included. Reviewers: resistor, chandlerc, spatel, hfinkel Reviewed By: hfinkel Subscribers: hfinkel, llvm-commits Differential Revision: http://reviews.llvm.org/D9147 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237812 91177308-0d34-0410-b5e6-96231b3b80d8 Pawel Bylica 5 years ago
2 changed file(s) with 52 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
17291729 ShiftBits = C1.countTrailingZeros();
17301730 }
17311731 NewC = NewC.lshr(ShiftBits);
1732 if (ShiftBits && isLegalICmpImmediate(NewC.getSExtValue())) {
1732 if (ShiftBits && NewC.getMinSignedBits() <= 64 &&
1733 isLegalICmpImmediate(NewC.getSExtValue())) {
17331734 EVT ShiftTy = DCI.isBeforeLegalize() ?
17341735 getPointerTy() : getShiftAmountTy(N0.getValueType());
17351736 EVT CmpTy = N0.getValueType();
0
1 ; RUN: llc < %s | FileCheck %s
2
3 ; CHECK-LABEL: test_ult
4 define i1 @test_ult(i256 %a) nounwind {
5 %1 = icmp ult i256 %a, -6432394258550908438
6 ret i1 %1
7 }
8
9 ; CHECK-LABEL: test_ule
10 define i1 @test_ule(i256 %a) nounwind {
11 %1 = icmp ule i256 %a, -6432394258550908438
12 ret i1 %1
13 }
14
15 ; CHECK-LABEL: test_ugt
16 define i1 @test_ugt(i256 %a) nounwind {
17 %1 = icmp ugt i256 %a, -6432394258550908438
18 ret i1 %1
19 }
20
21 ; CHECK-LABEL: test_uge
22 define i1 @test_uge(i256 %a) nounwind {
23 %1 = icmp uge i256 %a, -6432394258550908438
24 ret i1 %1
25 }
26
27 ; CHECK-LABEL: test_slt
28 define i1 @test_slt(i256 %a) nounwind {
29 %1 = icmp slt i256 %a, -6432394258550908438
30 ret i1 %1
31 }
32
33 ; CHECK-LABEL: test_sle
34 define i1 @test_sle(i256 %a) nounwind {
35 %1 = icmp sle i256 %a, -6432394258550908438
36 ret i1 %1
37 }
38
39 ; CHECK-LABEL: test_sgt
40 define i1 @test_sgt(i256 %a) nounwind {
41 %1 = icmp sgt i256 %a, -6432394258550908438
42 ret i1 %1
43 }
44
45 ; CHECK-LABEL: test_sge
46 define i1 @test_sge(i256 %a) nounwind {
47 %1 = icmp sge i256 %a, -6432394258550908438
48 ret i1 %1
49 }