Skip to content

Commit f2bb1d9

Browse files
committed
fix tests (thanks Claude)
1 parent a93a1e2 commit f2bb1d9

File tree

10 files changed

+86
-56
lines changed

10 files changed

+86
-56
lines changed

llvm/test/Transforms/InstCombine/and-or-icmps.ll

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -362,13 +362,23 @@ define <2 x i1> @and_ne_with_diff_one_splatvec(<2 x i32> %x) {
362362
; on an 'and' that should have been killed. It's not obvious
363363
; why, but removing anything hides the bug, hence the long test.
364364

365-
define void @simplify_before_foldAndOfICmps(ptr %p) {
365+
define void @simplify_before_foldAndOfICmps(ptr %p, ptr %A8) {
366366
; CHECK-LABEL: @simplify_before_foldAndOfICmps(
367-
; CHECK-NEXT: store i1 true, ptr [[P:%.*]], align 1
368-
; CHECK-NEXT: store ptr null, ptr [[P]], align 8
367+
; CHECK-NEXT: [[L7:%.*]] = load i16, ptr [[A8:%.*]], align 2
368+
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i16 [[L7]], -1
369+
; CHECK-NEXT: [[B11:%.*]] = zext i1 [[TMP1]] to i16
370+
; CHECK-NEXT: [[C10:%.*]] = icmp ugt i16 [[L7]], [[B11]]
371+
; CHECK-NEXT: [[C7:%.*]] = icmp slt i16 [[L7]], 0
372+
; CHECK-NEXT: [[C3:%.*]] = and i1 [[C7]], [[C10]]
373+
; CHECK-NEXT: [[TMP2:%.*]] = xor i1 [[C10]], true
374+
; CHECK-NEXT: [[C18:%.*]] = or i1 [[C7]], [[TMP2]]
375+
; CHECK-NEXT: [[TMP3:%.*]] = sext i1 [[C3]] to i64
376+
; CHECK-NEXT: [[G26:%.*]] = getelementptr i1, ptr null, i64 [[TMP3]]
377+
; CHECK-NEXT: store i16 [[L7]], ptr [[P:%.*]], align 2
378+
; CHECK-NEXT: store i1 [[C18]], ptr [[P]], align 1
379+
; CHECK-NEXT: store ptr [[G26]], ptr [[P]], align 8
369380
; CHECK-NEXT: ret void
370381
;
371-
%A8 = alloca i16
372382
%L7 = load i16, ptr %A8
373383
%G21 = getelementptr i16, ptr %A8, i8 -1
374384
%B11 = udiv i16 %L7, -1

llvm/test/Transforms/InstCombine/apint-shift.ll

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -562,11 +562,10 @@ define i40 @test26(i40 %A) {
562562

563563
; OSS-Fuzz #9880
564564
; https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9880
565-
define i177 @ossfuzz_9880(i177 %X) {
565+
define i177 @ossfuzz_9880(i177 %X, ptr %A) {
566566
; CHECK-LABEL: @ossfuzz_9880(
567-
; CHECK-NEXT: ret i177 poison
567+
; CHECK-NEXT: ret i177 0
568568
;
569-
%A = alloca i177
570569
%L1 = load i177, ptr %A
571570
%B = or i177 0, -1
572571
%B5 = udiv i177 %L1, %B

llvm/test/Transforms/InstCombine/call-cast-target.ll

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,17 @@ entry:
110110

111111
declare i1 @fn5(ptr byval({ i32, i32 }) align 4 %r)
112112

113-
define i1 @test5() {
114-
; CHECK-LABEL: define i1 @test5() {
115-
; CHECK-NEXT: [[TMP5:%.*]] = call i1 @fn5(i32 undef, i32 undef)
113+
define i1 @test5(ptr %ptr) {
114+
; CHECK-LABEL: define i1 @test5(ptr %ptr) {
115+
; CHECK-NEXT: [[TMP2:%.*]] = load i32, ptr [[PTR:%.*]], align 4
116+
; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds nuw i8, ptr [[PTR]], i32 4
117+
; CHECK-NEXT: [[TMP4:%.*]] = load i32, ptr [[TMP3]], align 4
118+
; CHECK-NEXT: [[TMP5:%.*]] = call i1 @fn5(i32 [[TMP2]], i32 [[TMP4]])
116119
; CHECK-NEXT: ret i1 [[TMP5]]
117120
;
118-
%1 = alloca { i32, i32 }, align 4
119-
%2 = getelementptr inbounds { i32, i32 }, ptr %1, i32 0, i32 0
121+
%2 = getelementptr inbounds { i32, i32 }, ptr %ptr, i32 0, i32 0
120122
%3 = load i32, ptr %2, align 4
121-
%4 = getelementptr inbounds { i32, i32 }, ptr %1, i32 0, i32 1
123+
%4 = getelementptr inbounds { i32, i32 }, ptr %ptr, i32 0, i32 1
122124
%5 = load i32, ptr %4, align 4
123125
%6 = call i1 @fn5(i32 %3, i32 %5)
124126
ret i1 %6

llvm/test/Transforms/InstCombine/fp-ret-bitcast.ll

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,17 @@ target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:1
1212
@"\01L_OBJC_METH_VAR_NAME_112" = internal global [15 x i8] c"whiteComponent\00", section "__TEXT,__cstring,cstring_literals"
1313
@"\01L_OBJC_SELECTOR_REFERENCES_81" = internal global ptr @"\01L_OBJC_METH_VAR_NAME_112", section "__OBJC,__message_refs,literal_pointers,no_dead_strip"
1414

15-
define void @bork() nounwind {
16-
; CHECK-LABEL: @bork(
15+
define void @bork(ptr %color, ptr %color.466) nounwind {
16+
; CHECK-LABEL: @bork(ptr %color, ptr %color.466) {
1717
; CHECK-NEXT: entry:
18+
; CHECK-NEXT: [[TMP103:%.*]] = load ptr, ptr [[COLOR:%.*]], align 4
1819
; CHECK-NEXT: [[TMP105:%.*]] = load ptr, ptr @"\01L_OBJC_SELECTOR_REFERENCES_81", align 4
19-
; CHECK-NEXT: [[TMP107:%.*]] = call float @objc_msgSend_fpret(ptr undef, ptr [[TMP105]]) #[[ATTR0:[0-9]+]]
20+
; CHECK-NEXT: [[TMP107:%.*]] = call float @objc_msgSend_fpret(ptr [[TMP103]], ptr [[TMP105]]) #[[ATTR0:[0-9]+]]
2021
; CHECK-NEXT: br label [[EXIT:%.*]]
2122
; CHECK: exit:
2223
; CHECK-NEXT: ret void
2324
;
2425
entry:
25-
%color = alloca ptr
26-
%color.466 = alloca ptr
2726
%tmp103 = load ptr, ptr %color, align 4
2827
store ptr %tmp103, ptr %color.466, align 4
2928
%tmp105 = load ptr, ptr @"\01L_OBJC_SELECTOR_REFERENCES_81", align 4

llvm/test/Transforms/InstCombine/getelementptr.ll

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -580,11 +580,11 @@ define i32 @test20_as1(ptr addrspace(1) %P, i32 %A, i32 %B) {
580580
}
581581

582582

583-
define i32 @test21() {
583+
define i32 @test21(ptr %pbob1) {
584584
; CHECK-LABEL: @test21(
585-
; CHECK-NEXT: ret i32 undef
585+
; CHECK-NEXT: [[RVAL:%.*]] = load i32, ptr [[PBOB1:%.*]], align 4
586+
; CHECK-NEXT: ret i32 [[RVAL]]
586587
;
587-
%pbob1 = alloca %intstruct
588588
%pbob2 = getelementptr %intstruct, ptr %pbob1
589589
%rval = load i32, ptr %pbob2
590590
ret i32 %rval
@@ -652,13 +652,16 @@ define i1 @test26(ptr %arr) {
652652
%struct.siginfo_t = type { i32, i32, i32, { { i32, i32, [0 x i8], %struct.sigval_t, i32 }, [88 x i8] } }
653653
%struct.sigval_t = type { ptr }
654654

655-
define i32 @test27(ptr %to, ptr %from) {
655+
define i32 @test27(ptr %to, ptr %from, ptr %from_addr) {
656656
; CHECK-LABEL: @test27(
657657
; CHECK-NEXT: entry:
658+
; CHECK-NEXT: [[T344:%.*]] = load ptr, ptr [[FROM_ADDR:%.*]], align 8
659+
; CHECK-NEXT: [[T348:%.*]] = getelementptr i8, ptr [[T344]], i64 24
660+
; CHECK-NEXT: [[T351:%.*]] = load i32, ptr [[T348]], align 8
661+
; CHECK-NEXT: [[T360:%.*]] = call i32 asm sideeffect "...", "=r,ir,*m,i,0,~{dirflag},~{fpsr},~{flags}"(i32 [[T351]], ptr elementtype([[STRUCT___LARGE_STRUCT:%.*]]) null, i32 -14, i32 0) #[[ATTR0:[0-9]+]]
658662
; CHECK-NEXT: unreachable
659663
;
660664
entry:
661-
%from_addr = alloca ptr
662665
%t344 = load ptr, ptr %from_addr, align 8
663666
%t345 = getelementptr %struct.siginfo_t, ptr %t344, i32 0, i32 3
664667
%t346 = getelementptr { { i32, i32, [0 x i8], %struct.sigval_t, i32 }, [88 x i8] }, ptr %t345, i32 0, i32 0
@@ -1335,13 +1338,14 @@ define ptr @D98588(ptr %c1, i64 %offset) {
13351338

13361339
declare noalias ptr @malloc(i64) nounwind allockind("alloc,uninitialized") allocsize(0)
13371340

1338-
define i32 @test_gep_bitcast_malloc(ptr %a) {
1341+
define i32 @test_gep_bitcast_malloc(ptr %a, ptr %call) {
13391342
; CHECK-LABEL: @test_gep_bitcast_malloc(
13401343
; CHECK-NEXT: entry:
1341-
; CHECK-NEXT: ret i32 undef
1344+
; CHECK-NEXT: [[G3:%.*]] = getelementptr inbounds i8, ptr [[CALL:%.*]], i64 12
1345+
; CHECK-NEXT: [[A_C:%.*]] = load i32, ptr [[G3]], align 4
1346+
; CHECK-NEXT: ret i32 [[A_C]]
13421347
;
13431348
entry:
1344-
%call = call noalias ptr @malloc(i64 16) #2
13451349
%g3 = getelementptr %struct.A, ptr %call, i32 0, i32 2
13461350
%a_c = load i32, ptr %g3, align 4
13471351
ret i32 %a_c

llvm/test/Transforms/InstCombine/multiple-uses-load-bitcast-select.ll

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
22
; RUN: opt < %s -passes=instcombine -S -data-layout="E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64" | FileCheck %s
33

4-
define void @PR35618(ptr %st1, ptr %st2) {
4+
define void @PR35618(ptr %st1, ptr %st2, ptr %y1, ptr %z1) {
55
; CHECK-LABEL: @PR35618(
6+
; CHECK-NEXT: [[LD1:%.*]] = load double, ptr [[Y1:%.*]], align 8
7+
; CHECK-NEXT: [[LD2:%.*]] = load double, ptr [[Z1:%.*]], align 8
8+
; CHECK-NEXT: [[TMP:%.*]] = fcmp olt double [[LD1]], [[LD2]]
9+
; CHECK-NEXT: [[TMP12_V:%.*]] = select i1 [[TMP]], double [[LD1]], double [[LD2]]
10+
; CHECK-NEXT: store double [[TMP12_V]], ptr [[ST1:%.*]], align 8
11+
; CHECK-NEXT: store double [[TMP12_V]], ptr [[ST2:%.*]], align 8
612
; CHECK-NEXT: ret void
713
;
8-
%y1 = alloca double
9-
%z1 = alloca double
1014
%ld1 = load double, ptr %y1
1115
%ld2 = load double, ptr %z1
1216
%tmp = fcmp olt double %ld1, %ld2
@@ -17,12 +21,17 @@ define void @PR35618(ptr %st1, ptr %st2) {
1721
ret void
1822
}
1923

20-
define void @PR35618_asan(ptr %st1, ptr %st2) sanitize_address {
24+
define void @PR35618_asan(ptr %st1, ptr %st2, ptr %y1, ptr %z1) sanitize_address {
2125
; CHECK-LABEL: @PR35618_asan(
26+
; CHECK-NEXT: [[LD1:%.*]] = load double, ptr [[Y1:%.*]], align 8
27+
; CHECK-NEXT: [[LD2:%.*]] = load double, ptr [[Z1:%.*]], align 8
28+
; CHECK-NEXT: [[TMP:%.*]] = fcmp olt double [[LD1]], [[LD2]]
29+
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[TMP]], ptr [[Y1]], ptr [[Z1]]
30+
; CHECK-NEXT: [[TMP12:%.*]] = load i64, ptr [[SEL]], align 8
31+
; CHECK-NEXT: store i64 [[TMP12]], ptr [[ST1:%.*]], align 8
32+
; CHECK-NEXT: store i64 [[TMP12]], ptr [[ST2:%.*]], align 8
2233
; CHECK-NEXT: ret void
2334
;
24-
%y1 = alloca double
25-
%z1 = alloca double
2635
%ld1 = load double, ptr %y1
2736
%ld2 = load double, ptr %z1
2837
%tmp = fcmp olt double %ld1, %ld2

llvm/test/Transforms/InstCombine/objsize.ll

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,18 @@ define i32 @foo() nounwind {
1414
ret i32 %1
1515
}
1616

17-
define ptr @bar() nounwind {
17+
define ptr @bar(ptr %retval) nounwind {
1818
; CHECK-LABEL: @bar(
1919
; CHECK-NEXT: entry:
2020
; CHECK-NEXT: br i1 true, label [[COND_TRUE:%.*]], label [[COND_FALSE:%.*]]
2121
; CHECK: cond.true:
22-
; CHECK-NEXT: ret ptr undef
22+
; CHECK-NEXT: [[TMP1:%.*]] = load ptr, ptr [[RETVAL:%.*]], align 8
23+
; CHECK-NEXT: ret ptr [[TMP1]]
2324
; CHECK: cond.false:
24-
; CHECK-NEXT: ret ptr undef
25+
; CHECK-NEXT: [[TMP2:%.*]] = load ptr, ptr [[RETVAL]], align 8
26+
; CHECK-NEXT: ret ptr [[TMP2]]
2527
;
2628
entry:
27-
%retval = alloca ptr
2829
%0 = call i32 @llvm.objectsize.i32.p0(ptr @a, i1 false, i1 false, i1 false)
2930
%cmp = icmp ne i32 %0, -1
3031
br i1 %cmp, label %cond.true, label %cond.false

llvm/test/Transforms/InstCombine/select-load.ll

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
55
target triple = "x86_64-grtev4-linux-gnu"
66

7-
define i32 @test_plain(i1 %f) {
7+
define i32 @test_plain(i1 %f, ptr %a, ptr %b) {
88
; CHECK-LABEL: @test_plain(
99
; CHECK-NEXT: entry:
10-
; CHECK-NEXT: ret i32 undef
10+
; CHECK-NEXT: [[A_VAL:%.*]] = load i32, ptr [[A:%.*]], align 8
11+
; CHECK-NEXT: [[B_VAL:%.*]] = load i32, ptr [[B:%.*]], align 8
12+
; CHECK-NEXT: [[L:%.*]] = select i1 [[F:%.*]], i32 [[A_VAL]], i32 [[B_VAL]]
13+
; CHECK-NEXT: ret i32 [[L]]
1114
;
1215
entry:
13-
%a = alloca i32, align 8
14-
%b = alloca i32, align 8
1516
%sel = select i1 %f, ptr %a, ptr %b
1617
%l = load i32, ptr %sel, align 8
1718
ret i32 %l
@@ -77,14 +78,15 @@ entry:
7778

7879
; Msan just propagates shadow, even if speculated load accesses uninitialized
7980
; value, instrumentation will select shadow of the desired value anyway.
80-
define i32 @test_msan(i1 %f) sanitize_memory {
81+
define i32 @test_msan(i1 %f, ptr %a, ptr %b) sanitize_memory {
8182
; CHECK-LABEL: @test_msan(
8283
; CHECK-NEXT: entry:
83-
; CHECK-NEXT: ret i32 undef
84+
; CHECK-NEXT: [[A_VAL:%.*]] = load i32, ptr [[A:%.*]], align 8
85+
; CHECK-NEXT: [[B_VAL:%.*]] = load i32, ptr [[B:%.*]], align 8
86+
; CHECK-NEXT: [[L:%.*]] = select i1 [[F:%.*]], i32 [[A_VAL]], i32 [[B_VAL]]
87+
; CHECK-NEXT: ret i32 [[L]]
8488
;
8589
entry:
86-
%a = alloca i32, align 8
87-
%b = alloca i32, align 8
8890
%sel = select i1 %f, ptr %a, ptr %b
8991
%l = load i32, ptr %sel, align 8
9092
ret i32 %l

llvm/test/Transforms/InstCombine/shift-amount-reassociation.ll

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,10 @@ define i32 @t11_shl_nsw_flag_preservation(i32 %x, i32 %y) {
156156

157157
; Reduced from https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=15587
158158
@X = external global i32
159-
define i64 @constantexpr() {
160-
; CHECK-LABEL: @constantexpr(
161-
; CHECK-NEXT: ret i64 poison
159+
define i64 @constantexpr(ptr %A) {
160+
; CHECK-LABEL: @constantexpr(ptr %A) {
161+
; CHECK-NEXT: ret i64 0
162162
;
163-
%A = alloca i64
164163
%L = load i64, ptr %A
165164
%V = add i64 ptrtoint (ptr @X to i64), 0
166165
%B2 = shl i64 %V, 0

llvm/test/Transforms/InstCombine/vscale_gep.ll

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,27 @@ define void @gep_bitcast(ptr %p) {
4141

4242
; These tests serve to verify code changes when underlying gep ptr is alloca.
4343
; This test is to verify 'inbounds' is added when it's valid to accumulate constant offset.
44-
define i32 @gep_alloca_inbounds_vscale_zero() {
45-
; CHECK-LABEL: @gep_alloca_inbounds_vscale_zero(
46-
; CHECK-NEXT: ret i32 undef
44+
define i32 @gep_alloca_inbounds_vscale_zero(ptr %a) {
45+
; CHECK-LABEL: @gep_alloca_inbounds_vscale_zero(ptr %a) {
46+
; CHECK-NEXT: [[TMP:%.*]] = getelementptr inbounds nuw i8, ptr [[A:%.*]], i64 8
47+
; CHECK-NEXT: [[LOAD:%.*]] = load i32, ptr [[TMP]], align 4
48+
; CHECK-NEXT: ret i32 [[LOAD]]
4749
;
48-
%a = alloca <vscale x 4 x i32>
4950
%tmp = getelementptr <vscale x 4 x i32>, ptr %a, i32 0, i32 2
5051
%load = load i32, ptr %tmp
5152
ret i32 %load
5253
}
5354

5455
; This test is to verify 'inbounds' is not added when a constant offset can not be determined at compile-time.
55-
define i32 @gep_alloca_inbounds_vscale_nonzero() {
56-
; CHECK-LABEL: @gep_alloca_inbounds_vscale_nonzero(
57-
; CHECK-NEXT: ret i32 undef
56+
define i32 @gep_alloca_inbounds_vscale_nonzero(ptr %a) {
57+
; CHECK-LABEL: @gep_alloca_inbounds_vscale_nonzero(ptr %a) {
58+
; CHECK-NEXT: [[TMP1:%.*]] = call i64 @llvm.vscale.i64()
59+
; CHECK-NEXT: [[TMP2:%.*]] = shl i64 [[TMP1]], 4
60+
; CHECK-NEXT: [[TMP3:%.*]] = getelementptr i8, ptr [[A:%.*]], i64 [[TMP2]]
61+
; CHECK-NEXT: [[TMP:%.*]] = getelementptr i8, ptr [[TMP3]], i64 8
62+
; CHECK-NEXT: [[LOAD:%.*]] = load i32, ptr [[TMP]], align 4
63+
; CHECK-NEXT: ret i32 [[LOAD]]
5864
;
59-
%a = alloca <vscale x 4 x i32>
6065
%tmp = getelementptr <vscale x 4 x i32>, ptr %a, i32 1, i32 2
6166
%load = load i32, ptr %tmp
6267
ret i32 %load

0 commit comments

Comments
 (0)