Open Quuxplusone opened 3 years ago
Bugzilla Link | PR51298 |
Status | NEW |
Importance | P enhancement |
Reported by | Zhendong Su (zhendong.su@inf.ethz.ch) |
Reported on | 2021-08-01 05:34:52 -0700 |
Last modified on | 2021-08-01 11:38:10 -0700 |
Version | trunk |
Hardware | PC All |
CC | llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, spatel+llvm@rotateright.com |
Fixed by commit(s) | |
Attachments | |
Blocks | |
Blocked by | |
See also |
A somewhat more properly reduced repro:
--------
int printf(const char *, ...);
short a, b;
static int c = 2, d, h;
int e, f, g, i, j, k;
short l(int m) { return a ? a : a << m; }
void q() {
for (; k; k++)
c = g;
c = 1;
}
int main() {
int n;
L:
for (; j < 1; j++)
n = 0;
for (; n < 10; n++) {
h = 0;
for (; h < 1; h++) {
b = i * c;
e = f = l(1) && 1;
if (c)
continue;
printf("%d\n", d);
}
}
printf("8");
if (a)
goto L;
return 0;
}
This is the bugpoint reduction that fails in llc:
; ModuleID = 'bugpoint-reduced-simplified.bc'
source_filename = "fuzz.cpp"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-
n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
@a = external dso_local local_unnamed_addr global i32, align 4
@c = external dso_local local_unnamed_addr global i32, align 4
@d = external dso_local local_unnamed_addr global i32, align 4
@f = external dso_local local_unnamed_addr global i32, align 4
@g = external dso_local local_unnamed_addr global i32, align 4
@h = external dso_local local_unnamed_addr global i32, align 4
@i = external dso_local local_unnamed_addr global i32, align 4
@b = external dso_local local_unnamed_addr global i16, align 2
define dso_local void @main() local_unnamed_addr #0 {
entry:
store i32 1, i32* @h, align 4
%i = load i32, i32* @f, align 4
%i1 = load i16, i16* @b, align 2
%tobool.not.i.us = icmp eq i16 %i1, 0
%shl.i.us = zext i1 %tobool.not.i.us to i16
%cond.i.us = shl i16 %i1, %shl.i.us
%tobool.us = icmp ne i16 %cond.i.us, 0
%d.promoted = load i32, i32* @d, align 4
%i2 = add i32 %d.promoted, -4
%shr.us = ashr i32 %i, 0
%conv.us = zext i1 %tobool.us to i32
store i32 %i2, i32* @d, align 4
store i32 %shr.us, i32* @g, align 4
store i32 %conv.us, i32* @c, align 4
store i32 0, i32* @i, align 4
%i3 = load i16, i16* @b, align 2
%tobool.not.i.us.1 = icmp eq i16 %i3, 0
%shl.i.us.1 = zext i1 %tobool.not.i.us.1 to i16
%cond.i.us.1 = shl i16 %i3, %shl.i.us.1
%tobool.us.1 = icmp ne i16 %cond.i.us.1, 0
%d.promoted.1 = load i32, i32* @d, align 4
%conv.us.1 = zext i1 %tobool.us.1 to i32
store i32 0, i32* @g, align 4
store i32 %conv.us.1, i32* @c, align 4
%i4 = load i32, i32* @f, align 4
%i5 = load i32, i32* @a, align 4
%d.promoted.2 = load i32, i32* @d, align 4
%i6 = add i32 %d.promoted.2, -4
%shr.us.2 = ashr i32 %i4, %i5
store i32 %i6, i32* @d, align 4
store i32 %shr.us.2, i32* @g, align 4
%i7 = load i16, i16* @b, align 2
%tobool.not.i.us.3 = icmp eq i16 %i7, 0
%shl.i.us.3 = zext i1 %tobool.not.i.us.3 to i16
%cond.i.us.3 = shl i16 %i7, %shl.i.us.3
%tobool.us.3 = icmp ne i16 %cond.i.us.3, 0
%d.promoted.3 = load i32, i32* @d, align 4
%i8 = add i32 %d.promoted.3, -4
%conv.us.3 = zext i1 %tobool.us.3 to i32
store i32 %i8, i32* @d, align 4
store i32 undef, i32* @g, align 4
store i32 %conv.us.3, i32* @c, align 4, !tbaa !1
%i9 = load i16, i16* @b, align 2
%tobool.not.i.us.4 = icmp eq i16 %i9, 0
%shl.i.us.4 = zext i1 %tobool.not.i.us.4 to i16
%cond.i.us.4 = shl i16 %i9, %shl.i.us.4
%tobool.us.4 = icmp ne i16 %cond.i.us.4, 0
%d.promoted.4 = load i32, i32* @d, align 4
%i10 = add i32 %d.promoted.4, -4
%conv.us.4 = zext i1 %tobool.us.4 to i32
store i32 %i10, i32* @d, align 4
store i32 0, i32* @g, align 4
store i32 %conv.us.4, i32* @c, align 4
%i11 = load i32, i32* @f, align 4
%d.promoted.5 = load i32, i32* @d, align 4
%i12 = add i32 %d.promoted.5, -4
%shr.us.5 = ashr i32 %i11, 0
store i32 %i12, i32* @d, align 4
store i32 %shr.us.5, i32* @g, align 4
store i32 0, i32* @i, align 4
store i32 0, i32* @g, align 4
unreachable
}
attributes #0 = { "tune-cpu"="generic" }
!llvm.ident = !{!0}
!0 = !{!"clang version 13.0.0 (https://github.com/llvm/llvm-project.git
afc760ef3527ef783a9f14f53583df2de8f0bd84)"}
!1 = !{!2, !2, i64 0}
!2 = !{!"int", !3, i64 0}
!3 = !{!"omnipotent char", !4, i64 0}
!4 = !{!"Simple C++ TBAA"}