Skip to content

Commit d5f0220

Browse files
committed
Added opt. Updated tests.
1 parent b784fa9 commit d5f0220

20 files changed

+74
-102
lines changed

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2370,6 +2370,17 @@ void computeKnownBits(const Value *V, const APInt &DemandedElts,
23702370
if (isa<PointerType>(V->getType())) {
23712371
Align Alignment = V->getPointerAlignment(Q.DL);
23722372
Known.Zero.setLowBits(Log2(Alignment));
2373+
for (auto *User : V->users()) {
2374+
if (auto *Load = dyn_cast<LoadInst>(User)) {
2375+
Known.Zero.setLowBits(Log2(Load->getAlign()));
2376+
}
2377+
if (auto *Store = dyn_cast<StoreInst>(User)) {
2378+
if (Store->getOperand(1) != V) {
2379+
continue;
2380+
}
2381+
Known.Zero.setLowBits(Log2(Store->getAlign()));
2382+
}
2383+
}
23732384
}
23742385

23752386
// computeKnownBitsFromContext strictly refines Known.

llvm/test/Analysis/ScalarEvolution/flags-from-poison.ll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ define void @test-add-scope-invariant(ptr %input, i32 %needle) {
102102
; CHECK-NEXT: %of_interest = add nuw nsw i32 %i.next, %offset
103103
; CHECK-NEXT: --> {(1 + %offset)<nuw><nsw>,+,1}<nuw><%loop> U: [1,0) S: [1,0) Exits: %needle LoopDispositions: { %loop: Computable }
104104
; CHECK-NEXT: %gep2 = getelementptr i32, ptr %input, i32 %of_interest
105-
; CHECK-NEXT: --> ((4 * (sext i32 {(1 + %offset)<nuw><nsw>,+,1}<nuw><%loop> to i64))<nsw> + %input) U: full-set S: full-set Exits: ((4 * (sext i32 %needle to i64))<nsw> + %input) LoopDispositions: { %loop: Computable }
105+
; CHECK-NEXT: --> ((4 * (sext i32 {(1 + %offset)<nuw><nsw>,+,1}<nuw><%loop> to i64))<nsw> + %input) U: [0,-3) S: [-9223372036854775808,9223372036854775805) Exits: ((4 * (sext i32 %needle to i64))<nsw> + %input) LoopDispositions: { %loop: Computable }
106106
; CHECK-NEXT: Determining loop execution counts for: @test-add-scope-invariant
107107
; CHECK-NEXT: Loop %loop: backedge-taken count is (-1 + (-1 * %offset) + %needle)
108108
; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i32 -1
@@ -174,7 +174,7 @@ define void @test-add-scope-bound-unkn-preheader(ptr %input, i32 %needle) {
174174
; CHECK-NEXT: %i.next = add nuw i32 %i, %offset
175175
; CHECK-NEXT: --> {%offset,+,%offset}<nuw><%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
176176
; CHECK-NEXT: %gep2 = getelementptr i32, ptr %input, i32 %i.next
177-
; CHECK-NEXT: --> ((4 * (sext i32 {%offset,+,%offset}<nuw><%loop> to i64))<nsw> + %input) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
177+
; CHECK-NEXT: --> ((4 * (sext i32 {%offset,+,%offset}<nuw><%loop> to i64))<nsw> + %input) U: [0,-3) S: [-9223372036854775808,9223372036854775805) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
178178
; CHECK-NEXT: Determining loop execution counts for: @test-add-scope-bound-unkn-preheader
179179
; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count.
180180
; CHECK-NEXT: Loop %loop: Unpredictable constant max backedge-taken count.
@@ -205,7 +205,7 @@ define void @test-add-scope-bound-unkn-preheader-neg1(ptr %input, i32 %needle) {
205205
; CHECK-NEXT: %i.next = add nuw i32 %i, %offset
206206
; CHECK-NEXT: --> {%offset,+,%offset}<nuw><%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
207207
; CHECK-NEXT: %gep2 = getelementptr i32, ptr %input, i32 %i.next
208-
; CHECK-NEXT: --> ((4 * (sext i32 {%offset,+,%offset}<nuw><%loop> to i64))<nsw> + %input) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
208+
; CHECK-NEXT: --> ((4 * (sext i32 {%offset,+,%offset}<nuw><%loop> to i64))<nsw> + %input) U: [0,-3) S: [-9223372036854775808,9223372036854775805) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
209209
; CHECK-NEXT: Determining loop execution counts for: @test-add-scope-bound-unkn-preheader-neg1
210210
; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count.
211211
; CHECK-NEXT: Loop %loop: Unpredictable constant max backedge-taken count.
@@ -237,7 +237,7 @@ define void @test-add-scope-bound-unkn-preheader-neg2(ptr %input, i32 %needle) {
237237
; CHECK-NEXT: %i.next = add nuw i32 %i, %offset
238238
; CHECK-NEXT: --> {%offset,+,%offset}<nw><%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
239239
; CHECK-NEXT: %gep2 = getelementptr i32, ptr %input, i32 %i.next
240-
; CHECK-NEXT: --> ((4 * (sext i32 {%offset,+,%offset}<nw><%loop> to i64))<nsw> + %input) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
240+
; CHECK-NEXT: --> ((4 * (sext i32 {%offset,+,%offset}<nw><%loop> to i64))<nsw> + %input) U: [0,-3) S: [-9223372036854775808,9223372036854775805) Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
241241
; CHECK-NEXT: Determining loop execution counts for: @test-add-scope-bound-unkn-preheader-neg2
242242
; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count.
243243
; CHECK-NEXT: Loop %loop: Unpredictable constant max backedge-taken count.
@@ -1641,7 +1641,7 @@ define i32 @pr28932() {
16411641
; CHECK-NEXT: %i = phi i32 [ %i3, %cont6 ], [ %pre7, %entry ]
16421642
; CHECK-NEXT: --> {%pre7,+,-1}<%for.cond> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %for.cond: Computable }
16431643
; CHECK-NEXT: %i1 = phi ptr [ %ph, %cont6 ], [ %pre, %entry ]
1644-
; CHECK-NEXT: --> %i1 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %for.cond: Variant }
1644+
; CHECK-NEXT: --> %i1 U: [0,-7) S: [-9223372036854775808,9223372036854775801) Exits: <<Unknown>> LoopDispositions: { %for.cond: Variant }
16451645
; CHECK-NEXT: %i3 = extractvalue { i32, i1 } %i2, 0
16461646
; CHECK-NEXT: --> {(-1 + %pre7),+,-1}<%for.cond> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %for.cond: Computable }
16471647
; CHECK-NEXT: %i4 = extractvalue { i32, i1 } %i2, 1

llvm/test/Analysis/ScalarEvolution/nsw.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ define void @test1(ptr %p) nounwind {
1313
; CHECK-NEXT: %tmp2 = sext i32 %i.01 to i64
1414
; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%bb> U: [0,-9223372036854775808) S: [0,-9223372036854775808) Exits: <<Unknown>> LoopDispositions: { %bb: Computable }
1515
; CHECK-NEXT: %tmp3 = getelementptr double, ptr %p, i64 %tmp2
16-
; CHECK-NEXT: --> {%p,+,8}<%bb> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb: Computable }
16+
; CHECK-NEXT: --> {%p,+,8}<%bb> U: [0,-7) S: [-9223372036854775808,9223372036854775801) Exits: <<Unknown>> LoopDispositions: { %bb: Computable }
1717
; CHECK-NEXT: %tmp6 = sext i32 %i.01 to i64
1818
; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%bb> U: [0,-9223372036854775808) S: [0,-9223372036854775808) Exits: <<Unknown>> LoopDispositions: { %bb: Computable }
1919
; CHECK-NEXT: %tmp7 = getelementptr double, ptr %p, i64 %tmp6
20-
; CHECK-NEXT: --> {%p,+,8}<%bb> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb: Computable }
20+
; CHECK-NEXT: --> {%p,+,8}<%bb> U: [0,-7) S: [-9223372036854775808,9223372036854775801) Exits: <<Unknown>> LoopDispositions: { %bb: Computable }
2121
; CHECK-NEXT: %tmp8 = add nsw i32 %i.01, 1
2222
; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%bb> U: [1,-2147483648) S: [1,-2147483648) Exits: <<Unknown>> LoopDispositions: { %bb: Computable }
2323
; CHECK-NEXT: %p.gep = getelementptr double, ptr %p, i32 %tmp8
24-
; CHECK-NEXT: --> {(8 + %p),+,8}<%bb> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb: Computable }
24+
; CHECK-NEXT: --> {(8 + %p),+,8}<%bb> U: [0,-7) S: [-9223372036854775808,9223372036854775801) Exits: <<Unknown>> LoopDispositions: { %bb: Computable }
2525
; CHECK-NEXT: %phitmp = sext i32 %tmp8 to i64
2626
; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%bb> U: [1,-9223372036854775808) S: [1,-9223372036854775808) Exits: <<Unknown>> LoopDispositions: { %bb: Computable }
2727
; CHECK-NEXT: %tmp9 = getelementptr inbounds double, ptr %p, i64 %phitmp
28-
; CHECK-NEXT: --> {(8 + %p),+,8}<%bb> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb: Computable }
28+
; CHECK-NEXT: --> {(8 + %p),+,8}<%bb> U: [0,-7) S: [-9223372036854775808,9223372036854775801) Exits: <<Unknown>> LoopDispositions: { %bb: Computable }
2929
; CHECK-NEXT: Determining loop execution counts for: @test1
3030
; CHECK-NEXT: Loop %bb: Unpredictable backedge-taken count.
3131
; CHECK-NEXT: Loop %bb: Unpredictable constant max backedge-taken count.

llvm/test/Transforms/Coroutines/coro-retcon-alloca-opaque-ptr.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ define {ptr, ptr, i32} @f(ptr %buffer, i32 %n, { i32 } %dummy) {
99
; CHECK-LABEL: @f(
1010
; CHECK-NEXT: coro.return:
1111
; CHECK-NEXT: [[N_VAL_SPILL_ADDR:%.*]] = getelementptr inbounds nuw i8, ptr [[BUFFER:%.*]], i64 8
12-
; CHECK-NEXT: store i32 [[N:%.*]], ptr [[N_VAL_SPILL_ADDR]], align 4
12+
; CHECK-NEXT: store i32 [[N:%.*]], ptr [[N_VAL_SPILL_ADDR]], align 8
1313
; CHECK-NEXT: [[TMP0:%.*]] = tail call ptr @allocate(i32 [[N]])
1414
; CHECK-NEXT: store ptr [[TMP0]], ptr [[BUFFER]], align 8
1515
; CHECK-NEXT: [[TMP1:%.*]] = insertvalue { ptr, ptr, i32 } { ptr @f.resume.0, ptr poison, i32 poison }, ptr [[TMP0]], 1

llvm/test/Transforms/Coroutines/coro-retcon-alloca.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ define {ptr, ptr, i32} @f(ptr %buffer, i32 %n) {
88
; CHECK-LABEL: @f(
99
; CHECK-NEXT: coro.return:
1010
; CHECK-NEXT: [[N_VAL_SPILL_ADDR:%.*]] = getelementptr inbounds nuw i8, ptr [[BUFFER:%.*]], i64 8
11-
; CHECK-NEXT: store i32 [[N:%.*]], ptr [[N_VAL_SPILL_ADDR]], align 4
11+
; CHECK-NEXT: store i32 [[N:%.*]], ptr [[N_VAL_SPILL_ADDR]], align 8
1212
; CHECK-NEXT: [[TMP0:%.*]] = tail call ptr @allocate(i32 [[N]])
1313
; CHECK-NEXT: store ptr [[TMP0]], ptr [[BUFFER]], align 8
1414
; CHECK-NEXT: [[TMP1:%.*]] = insertvalue { ptr, ptr, i32 } { ptr @f.resume.0, ptr poison, i32 poison }, ptr [[TMP0]], 1

llvm/test/Transforms/Coroutines/coro-retcon-once-value.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ declare void @print(i32)
160160
; CHECK-NEXT: [[TMP0:%.*]] = tail call ptr @allocate(i32 16)
161161
; CHECK-NEXT: store ptr [[TMP0]], ptr [[BUFFER:%.*]], align 8
162162
; CHECK-NEXT: [[VAL_SPILL_ADDR:%.*]] = getelementptr inbounds nuw i8, ptr [[TMP0]], i64 8
163-
; CHECK-NEXT: store i32 [[VAL:%.*]], ptr [[VAL_SPILL_ADDR]], align 4
163+
; CHECK-NEXT: store i32 [[VAL:%.*]], ptr [[VAL_SPILL_ADDR]], align 8
164164
; CHECK-NEXT: store ptr [[ARRAY:%.*]], ptr [[TMP0]], align 8
165165
; CHECK-NEXT: [[LOAD:%.*]] = load i32, ptr [[ARRAY]], align 4
166166
; CHECK-NEXT: [[LOAD_POS:%.*]] = icmp sgt i32 [[LOAD]], 0
@@ -181,7 +181,7 @@ declare void @print(i32)
181181
; CHECK-NEXT: br label [[COROEND]]
182182
; CHECK: CoroEnd:
183183
; CHECK-NEXT: [[VAL_RELOAD_ADDR:%.*]] = getelementptr inbounds nuw i8, ptr [[TMP2]], i64 8
184-
; CHECK-NEXT: [[VAL_RELOAD:%.*]] = load i32, ptr [[VAL_RELOAD_ADDR]], align 4
184+
; CHECK-NEXT: [[VAL_RELOAD:%.*]] = load i32, ptr [[VAL_RELOAD_ADDR]], align 8
185185
; CHECK-NEXT: [[NEW_VAL:%.*]] = add i32 [[VAL_RELOAD]], 123
186186
; CHECK-NEXT: tail call void @deallocate(ptr [[TMP2]])
187187
; CHECK-NEXT: [[TMP3:%.*]] = insertvalue { ptr, i32, ptr } { ptr null, i32 poison, ptr poison }, i32 [[NEW_VAL]], 1
@@ -199,7 +199,7 @@ declare void @print(i32)
199199
; CHECK-NEXT: br label [[COROEND]]
200200
; CHECK: CoroEnd:
201201
; CHECK-NEXT: [[VAL_RELOAD_ADDR:%.*]] = getelementptr inbounds nuw i8, ptr [[TMP2]], i64 8
202-
; CHECK-NEXT: [[VAL_RELOAD:%.*]] = load i32, ptr [[VAL_RELOAD_ADDR]], align 4
202+
; CHECK-NEXT: [[VAL_RELOAD:%.*]] = load i32, ptr [[VAL_RELOAD_ADDR]], align 8
203203
; CHECK-NEXT: [[NEW_VAL:%.*]] = add i32 [[VAL_RELOAD]], 123
204204
; CHECK-NEXT: tail call void @deallocate(ptr [[TMP2]])
205205
; CHECK-NEXT: [[TMP3:%.*]] = insertvalue { ptr, i32, ptr } { ptr null, i32 poison, ptr poison }, i32 [[NEW_VAL]], 1

llvm/test/Transforms/InferAlignment/propagate-from-other-load-stores.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ define void @no_prop_align(ptr %v, ptr %vout, i1 %cond) {
9595
; CHECK-NEXT: br label %[[END:.*]]
9696
; CHECK: [[BRANCH2]]:
9797
; CHECK-NEXT: [[DOTUNPACK2_ELT12:%.*]] = getelementptr inbounds nuw i8, ptr [[V]], i64 16
98-
; CHECK-NEXT: [[DOTUNPACK2_UNPACK13:%.*]] = load float, ptr [[DOTUNPACK2_ELT12]], align 4
98+
; CHECK-NEXT: [[DOTUNPACK2_UNPACK13:%.*]] = load float, ptr [[DOTUNPACK2_ELT12]], align 16
9999
; CHECK-NEXT: [[DOTUNPACK2_ELT14:%.*]] = getelementptr inbounds nuw i8, ptr [[V]], i64 20
100100
; CHECK-NEXT: [[DOTUNPACK2_UNPACK15:%.*]] = load float, ptr [[DOTUNPACK2_ELT14]], align 4
101101
; CHECK-NEXT: [[DOTELT3:%.*]] = getelementptr inbounds nuw i8, ptr [[V]], i64 24

llvm/test/Transforms/InstCombine/assume-align.ll

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,8 @@ define void @f1(ptr %a) {
77
; CHECK-LABEL: @f1(
88
; CHECK-NEXT: entry:
99
; CHECK-NEXT: [[PTR:%.*]] = getelementptr inbounds nuw i8, ptr [[A:%.*]], i64 4
10-
; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[PTR]] to i64
11-
; CHECK-NEXT: [[TMP1:%.*]] = and i64 [[TMP0]], 3
12-
; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i64 [[TMP1]], 0
13-
; CHECK-NEXT: br i1 [[TMP2]], label [[IF_THEN:%.*]], label [[IF_END:%.*]]
14-
; CHECK: if.then:
1510
; CHECK-NEXT: call void @llvm.assume(i1 true) [ "align"(ptr [[PTR]], i64 4) ]
1611
; CHECK-NEXT: store i32 4, ptr [[PTR]], align 4
17-
; CHECK-NEXT: br label [[IF_END]]
18-
; CHECK: if.end:
1912
; CHECK-NEXT: ret void
2013
;
2114
entry:

llvm/test/Transforms/InstCombine/assume.ll

Lines changed: 17 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,13 @@ declare void @llvm.assume(i1) #1
1111
; Check that the assume has not been removed:
1212

1313
define i32 @align_to_bundle(ptr %a) #0 {
14-
; DEFAULT-LABEL: @align_to_bundle(
15-
; DEFAULT-NEXT: [[T0:%.*]] = load i32, ptr [[A:%.*]], align 4
16-
; DEFAULT-NEXT: [[PTRINT:%.*]] = ptrtoint ptr [[A]] to i64
17-
; DEFAULT-NEXT: [[MASKEDPTR:%.*]] = and i64 [[PTRINT]], 31
18-
; DEFAULT-NEXT: [[MASKCOND:%.*]] = icmp eq i64 [[MASKEDPTR]], 0
19-
; DEFAULT-NEXT: tail call void @llvm.assume(i1 [[MASKCOND]])
20-
; DEFAULT-NEXT: ret i32 [[T0]]
21-
;
22-
; BUNDLES-LABEL: @align_to_bundle(
23-
; BUNDLES-NEXT: [[T0:%.*]] = load i32, ptr [[A:%.*]], align 4
24-
; BUNDLES-NEXT: call void @llvm.assume(i1 true) [ "align"(ptr [[A]], i64 32) ]
25-
; BUNDLES-NEXT: ret i32 [[T0]]
14+
; CHECK-LABEL: @align_to_bundle(
15+
; CHECK-NEXT: [[T0:%.*]] = load i32, ptr [[A:%.*]], align 4
16+
; CHECK-NEXT: [[PTRINT:%.*]] = ptrtoint ptr [[A]] to i64
17+
; CHECK-NEXT: [[MASKEDPTR:%.*]] = and i64 [[PTRINT]], 28
18+
; CHECK-NEXT: [[MASKCOND:%.*]] = icmp eq i64 [[MASKEDPTR]], 0
19+
; CHECK-NEXT: tail call void @llvm.assume(i1 [[MASKCOND]])
20+
; CHECK-NEXT: ret i32 [[T0]]
2621
;
2722
%t0 = load i32, ptr %a, align 4
2823
%ptrint = ptrtoint ptr %a to i64
@@ -55,18 +50,9 @@ define i32 @align_to_bundle_ptrtoaddr(ptr %a) #0 {
5550
}
5651

5752
define i32 @align_assume_trunc_cond(ptr %a) #0 {
58-
; DEFAULT-LABEL: @align_assume_trunc_cond(
59-
; DEFAULT-NEXT: [[T0:%.*]] = load i32, ptr [[A:%.*]], align 4
60-
; DEFAULT-NEXT: [[PTRINT:%.*]] = ptrtoint ptr [[A]] to i64
61-
; DEFAULT-NEXT: [[TRUNC:%.*]] = trunc i64 [[PTRINT]] to i1
62-
; DEFAULT-NEXT: [[MASKCOND:%.*]] = xor i1 [[TRUNC]], true
63-
; DEFAULT-NEXT: tail call void @llvm.assume(i1 [[MASKCOND]])
64-
; DEFAULT-NEXT: ret i32 [[T0]]
65-
;
66-
; BUNDLES-LABEL: @align_assume_trunc_cond(
67-
; BUNDLES-NEXT: [[T0:%.*]] = load i32, ptr [[A:%.*]], align 4
68-
; BUNDLES-NEXT: call void @llvm.assume(i1 true) [ "align"(ptr [[A]], i64 2) ]
69-
; BUNDLES-NEXT: ret i32 [[T0]]
53+
; CHECK-LABEL: @align_assume_trunc_cond(
54+
; CHECK-NEXT: [[T0:%.*]] = load i32, ptr [[A:%.*]], align 4
55+
; CHECK-NEXT: ret i32 [[T0]]
7056
;
7157
%t0 = load i32, ptr %a, align 4
7258
%ptrint = ptrtoint ptr %a to i64
@@ -79,18 +65,13 @@ define i32 @align_assume_trunc_cond(ptr %a) #0 {
7965
; Same check as in @foo1, but make sure it works if the assume is first too.
8066

8167
define i32 @foo2(ptr %a) #0 {
82-
; DEFAULT-LABEL: @foo2(
83-
; DEFAULT-NEXT: [[PTRINT:%.*]] = ptrtoint ptr [[A:%.*]] to i64
84-
; DEFAULT-NEXT: [[MASKEDPTR:%.*]] = and i64 [[PTRINT]], 31
85-
; DEFAULT-NEXT: [[MASKCOND:%.*]] = icmp eq i64 [[MASKEDPTR]], 0
86-
; DEFAULT-NEXT: tail call void @llvm.assume(i1 [[MASKCOND]])
87-
; DEFAULT-NEXT: [[T0:%.*]] = load i32, ptr [[A]], align 4
88-
; DEFAULT-NEXT: ret i32 [[T0]]
89-
;
90-
; BUNDLES-LABEL: @foo2(
91-
; BUNDLES-NEXT: call void @llvm.assume(i1 true) [ "align"(ptr [[A:%.*]], i64 32) ]
92-
; BUNDLES-NEXT: [[T0:%.*]] = load i32, ptr [[A]], align 4
93-
; BUNDLES-NEXT: ret i32 [[T0]]
68+
; CHECK-LABEL: @foo2(
69+
; CHECK-NEXT: [[PTRINT:%.*]] = ptrtoint ptr [[A:%.*]] to i64
70+
; CHECK-NEXT: [[MASKEDPTR:%.*]] = and i64 [[PTRINT]], 28
71+
; CHECK-NEXT: [[MASKCOND:%.*]] = icmp eq i64 [[MASKEDPTR]], 0
72+
; CHECK-NEXT: tail call void @llvm.assume(i1 [[MASKCOND]])
73+
; CHECK-NEXT: [[T0:%.*]] = load i32, ptr [[A]], align 4
74+
; CHECK-NEXT: ret i32 [[T0]]
9475
;
9576
%ptrint = ptrtoint ptr %a to i64
9677
%maskedptr = and i64 %ptrint, 31

llvm/test/Transforms/InstCombine/assume_inevitable.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ define i32 @assume_inevitable(ptr %a, ptr %b, ptr %c) {
1717
; CHECK-NEXT: [[OBJSZ:%.*]] = call i64 @llvm.objectsize.i64.p0(ptr [[C:%.*]], i1 false, i1 false, i1 false)
1818
; CHECK-NEXT: store i64 [[OBJSZ]], ptr [[M_A]], align 4
1919
; CHECK-NEXT: [[PTRINT:%.*]] = ptrtoint ptr [[A]] to i64
20-
; CHECK-NEXT: [[MASKEDPTR:%.*]] = and i64 [[PTRINT]], 31
20+
; CHECK-NEXT: [[MASKEDPTR:%.*]] = and i64 [[PTRINT]], 28
2121
; CHECK-NEXT: [[MASKCOND:%.*]] = icmp eq i64 [[MASKEDPTR]], 0
2222
; CHECK-NEXT: tail call void @llvm.assume(i1 [[MASKCOND]])
2323
; CHECK-NEXT: ret i32 [[TMP0]]

0 commit comments

Comments
 (0)