Skip to content

Commit 43a1fcb

Browse files
committed
more fixes, add xfail for pre-existing failure
1 parent 72a77c1 commit 43a1fcb

File tree

3 files changed

+65
-18
lines changed

3 files changed

+65
-18
lines changed

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

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -362,23 +362,13 @@ 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, ptr %A8) {
365+
define void @simplify_before_foldAndOfICmps(ptr %p) {
366366
; CHECK-LABEL: @simplify_before_foldAndOfICmps(
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
367+
; CHECK-NEXT: store i1 true, ptr [[P:%.*]], align 1
368+
; CHECK-NEXT: store ptr null, ptr [[P]], align 8
380369
; CHECK-NEXT: ret void
381370
;
371+
%A8 = alloca i16
382372
%L7 = load i16, ptr %A8
383373
%G21 = getelementptr i16, ptr %A8, i8 -1
384374
%B11 = udiv i16 %L7, -1
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2+
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
3+
; XFAIL: *
4+
5+
; This is a fuzzer-generated test that would assert because
6+
; we'd get into foldAndOfICmps() without running InstSimplify
7+
; on an 'and' that should have been killed. It's not obvious
8+
; why, but removing anything hides the bug, hence the long test.
9+
10+
define void @simplify_before_foldAndOfICmps(ptr %p, ptr %A8) {
11+
; CHECK-LABEL: @simplify_before_foldAndOfICmps(
12+
; CHECK-NEXT: [[L7:%.*]] = load i16, ptr [[A8:%.*]], align 2
13+
; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i16 [[L7]], -1
14+
; CHECK-NEXT: [[B11:%.*]] = zext i1 [[TMP1]] to i16
15+
; CHECK-NEXT: [[C10:%.*]] = icmp ugt i16 [[L7]], [[B11]]
16+
; CHECK-NEXT: [[C7:%.*]] = icmp slt i16 [[L7]], 0
17+
; CHECK-NEXT: [[C3:%.*]] = and i1 [[C7]], [[C10]]
18+
; CHECK-NEXT: [[TMP2:%.*]] = xor i1 [[C10]], true
19+
; CHECK-NEXT: [[C18:%.*]] = or i1 [[C7]], [[TMP2]]
20+
; CHECK-NEXT: [[TMP3:%.*]] = sext i1 [[C3]] to i64
21+
; CHECK-NEXT: [[G26:%.*]] = getelementptr i1, ptr null, i64 [[TMP3]]
22+
; CHECK-NEXT: store i16 [[L7]], ptr [[P:%.*]], align 2
23+
; CHECK-NEXT: store i1 [[C18]], ptr [[P]], align 1
24+
; CHECK-NEXT: store ptr [[G26]], ptr [[P]], align 8
25+
; CHECK-NEXT: ret void
26+
;
27+
%L7 = load i16, ptr %A8
28+
%G21 = getelementptr i16, ptr %A8, i8 -1
29+
%B11 = udiv i16 %L7, -1
30+
%G4 = getelementptr i16, ptr %A8, i16 %B11
31+
%L2 = load i16, ptr %G4
32+
%L = load i16, ptr %G4
33+
%B23 = mul i16 %B11, %B11
34+
%L4 = load i16, ptr %A8
35+
%B21 = sdiv i16 %L7, %L4
36+
%B7 = sub i16 0, %B21
37+
%B18 = mul i16 %B23, %B7
38+
%C10 = icmp ugt i16 %L, %B11
39+
%B20 = and i16 %L7, %L2
40+
%B1 = mul i1 %C10, true
41+
%C5 = icmp sle i16 %B21, %L
42+
%C11 = icmp ule i16 %B21, %L
43+
%C7 = icmp slt i16 %B20, 0
44+
%B29 = srem i16 %L4, %B18
45+
%B15 = add i1 %C7, %C10
46+
%B19 = add i1 %C11, %B15
47+
%C6 = icmp sge i1 %C11, %B19
48+
%B33 = or i16 %B29, %L4
49+
%C13 = icmp uge i1 %C5, %B1
50+
%C3 = icmp ult i1 %C13, %C6
51+
store i16 undef, ptr %G21
52+
%C18 = icmp ule i1 %C10, %C7
53+
%G26 = getelementptr i1, ptr null, i1 %C3
54+
store i16 %B33, ptr %p
55+
store i1 %C18, ptr %p
56+
store ptr %G26, ptr %p
57+
ret void
58+
}

llvm/test/Transforms/InstCombine/getelementptr.ll

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,14 +1338,13 @@ define ptr @D98588(ptr %c1, i64 %offset) {
13381338

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

1341-
define i32 @test_gep_bitcast_malloc(ptr %a, ptr %call) {
1341+
define i32 @test_gep_bitcast_malloc(ptr %a) {
13421342
; CHECK-LABEL: @test_gep_bitcast_malloc(
13431343
; CHECK-NEXT: entry:
1344-
; CHECK-NEXT: [[G3:%.*]] = getelementptr i8, ptr [[CALL:%.*]], i64 12
1345-
; CHECK-NEXT: [[A_C:%.*]] = load i32, ptr [[G3]], align 4
1346-
; CHECK-NEXT: ret i32 [[A_C]]
1344+
; CHECK-NEXT: ret i32 undef
13471345
;
13481346
entry:
1347+
%call = call noalias ptr @malloc(i64 16) #2
13491348
%g3 = getelementptr %struct.A, ptr %call, i32 0, i32 2
13501349
%a_c = load i32, ptr %g3, align 4
13511350
ret i32 %a_c

0 commit comments

Comments
 (0)