Skip to content

Commit 6e518a3

Browse files
author
James Molloy
committed
[DemandedBits] Revert r249687 due to PR26071
This regresses a test in LoopVectorize, so I'll need to go away and think about how to solve this in a way that isn't broken. From the writeup in PR26071: What's happening is that ComputeKnownZeroes is telling us that all bits except the LSB are zero. We're then deciding that only the LSB needs to be demanded from the icmp's inputs. This is where we're wrong - we're assuming that after simplification the bits that were known zero will continue to be known zero. But they're not - during trivialization the upper bits get changed (because an XOR isn't shrunk), so the icmp fails. The fault is in demandedbits - its contract does clearly state that a non-demanded bit may either be zero or one. llvm-svn: 259649
1 parent 739ae64 commit 6e518a3

File tree

3 files changed

+0
-72
lines changed

3 files changed

+0
-72
lines changed

llvm/lib/Analysis/DemandedBits.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -241,13 +241,6 @@ void DemandedBits::determineLiveOperandBits(
241241
if (OperandNo != 0)
242242
AB = AOut;
243243
break;
244-
case Instruction::ICmp:
245-
// Count the number of leading zeroes in each operand.
246-
ComputeKnownBits(BitWidth, UserI->getOperand(0), UserI->getOperand(1));
247-
auto NumLeadingZeroes = std::min(KnownZero.countLeadingOnes(),
248-
KnownZero2.countLeadingOnes());
249-
AB = ~APInt::getHighBitsSet(BitWidth, NumLeadingZeroes);
250-
break;
251244
}
252245
}
253246

llvm/test/Analysis/DemandedBits/basic.ll

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,3 @@ define i8 @test_mul(i32 %a, i32 %b) {
1010
%3 = trunc i32 %2 to i8
1111
ret i8 %3
1212
}
13-
14-
; CHECK-LABEL: 'test_icmp1'
15-
; CHECK-DAG: DemandedBits: 0x1 for %3 = icmp eq i32 %1, %2
16-
; CHECK-DAG: DemandedBits: 0xFFF for %1 = and i32 %a, 255
17-
; CHECK-DAG: DemandedBits: 0xFFF for %2 = shl i32 %1, 4
18-
define i1 @test_icmp1(i32 %a, i32 %b) {
19-
%1 = and i32 %a, 255
20-
%2 = shl i32 %1, 4
21-
%3 = icmp eq i32 %1, %2
22-
ret i1 %3
23-
}
24-
25-
; CHECK-LABEL: 'test_icmp2'
26-
; CHECK-DAG: DemandedBits: 0x1 for %3 = icmp eq i32 %1, %2
27-
; CHECK-DAG: DemandedBits: 0xFFF for %1 = and i32 %a, 255
28-
; CHECK-DAG: DemandedBits: 0xFF for %2 = ashr i32 %1, 4
29-
define i1 @test_icmp2(i32 %a, i32 %b) {
30-
%1 = and i32 %a, 255
31-
%2 = ashr i32 %1, 4
32-
%3 = icmp eq i32 %1, %2
33-
ret i1 %3
34-
}
35-
36-
; CHECK-LABEL: 'test_icmp3'
37-
; CHECK-DAG: DemandedBits: 0xFFFFFFFF for %1 = and i32 %a, 255
38-
; CHECK-DAG: DemandedBits: 0x1 for %2 = icmp eq i32 -1, %1
39-
define i1 @test_icmp3(i32 %a) {
40-
%1 = and i32 %a, 255
41-
%2 = icmp eq i32 -1, %1
42-
ret i1 %2
43-
}

llvm/test/Transforms/LoopVectorize/AArch64/loop-vectorization-factors.ll

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -205,39 +205,5 @@ for.body: ; preds = %for.body, %for.body
205205
br i1 %exitcond, label %for.cond.cleanup, label %for.body
206206
}
207207

208-
; CHECK-LABEL: @add_g
209-
; CHECK: load <16 x i8>
210-
; CHECK: xor <16 x i8>
211-
; CHECK: icmp ult <16 x i8>
212-
; CHECK: select <16 x i1> {{.*}}, <16 x i8>
213-
; CHECK: store <16 x i8>
214-
define void @add_g(i8* noalias nocapture readonly %p, i8* noalias nocapture readonly %q, i8* noalias nocapture %r, i8 %arg1, i32 %len) #0 {
215-
%1 = icmp sgt i32 %len, 0
216-
br i1 %1, label %.lr.ph, label %._crit_edge
217-
218-
.lr.ph: ; preds = %0
219-
%2 = sext i8 %arg1 to i64
220-
br label %3
221-
222-
._crit_edge: ; preds = %3, %0
223-
ret void
224-
225-
; <label>:3 ; preds = %3, %.lr.ph
226-
%indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %3 ]
227-
%x4 = getelementptr inbounds i8, i8* %p, i64 %indvars.iv
228-
%x5 = load i8, i8* %x4
229-
%x7 = getelementptr inbounds i8, i8* %q, i64 %indvars.iv
230-
%x8 = load i8, i8* %x7
231-
%x9 = zext i8 %x5 to i32
232-
%x10 = xor i32 %x9, 255
233-
%x11 = icmp ult i32 %x10, 24
234-
%x12 = select i1 %x11, i32 %x10, i32 24
235-
%x13 = trunc i32 %x12 to i8
236-
store i8 %x13, i8* %x4
237-
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
238-
%lftr.wideiv = trunc i64 %indvars.iv.next to i32
239-
%exitcond = icmp eq i32 %lftr.wideiv, %len
240-
br i1 %exitcond, label %._crit_edge, label %3
241-
}
242208

243209
attributes #0 = { nounwind }

0 commit comments

Comments
 (0)