brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.1 KiB · 23a278c Raw
155 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -passes=instcombine -S | FileCheck %s3 4target datalayout = "n32"5 6define i32 @sterix(i32, i8, i64) {7; CHECK-LABEL: @sterix(8; CHECK-NEXT:  entry:9; CHECK-NEXT:    [[CONV:%.*]] = zext i32 [[TMP0:%.*]] to i6410; CHECK-NEXT:    [[CONV1:%.*]] = sext i8 [[TMP1:%.*]] to i3211; CHECK-NEXT:    [[MUL:%.*]] = mul i32 [[CONV1]], 194596487812; CHECK-NEXT:    [[SH_PROM:%.*]] = trunc i64 [[TMP2:%.*]] to i3213; CHECK-NEXT:    [[SHR:%.*]] = lshr i32 [[MUL]], [[SH_PROM]]14; CHECK-NEXT:    [[CONV2:%.*]] = zext i32 [[SHR]] to i6415; CHECK-NEXT:    [[MUL3:%.*]] = mul nuw nsw i64 [[CONV]], [[CONV2]]16; CHECK-NEXT:    [[TOBOOL_NOT:%.*]] = icmp samesign ult i64 [[MUL3]], 429496729617; CHECK-NEXT:    br i1 [[TOBOOL_NOT]], label [[LOR_RHS:%.*]], label [[LOR_END:%.*]]18; CHECK:       lor.rhs:19; CHECK-NEXT:    [[AND:%.*]] = and i64 [[TMP2]], [[MUL3]]20; CHECK-NEXT:    [[TOBOOL7_NOT:%.*]] = icmp eq i64 [[AND]], 021; CHECK-NEXT:    [[TMP3:%.*]] = zext i1 [[TOBOOL7_NOT]] to i3222; CHECK-NEXT:    br label [[LOR_END]]23; CHECK:       lor.end:24; CHECK-NEXT:    [[CONV8:%.*]] = phi i32 [ 1, [[ENTRY:%.*]] ], [ [[TMP3]], [[LOR_RHS]] ]25; CHECK-NEXT:    ret i32 [[CONV8]]26;27entry:28  %conv = zext i32 %0 to i6429  %conv1 = sext i8 %1 to i3230  %mul = mul i32 %conv1, 194596487831  %sh_prom = trunc i64 %2 to i3232  %shr = lshr i32 %mul, %sh_prom33  %conv2 = zext i32 %shr to i6434  %mul3 = mul nuw nsw i64 %conv, %conv235  %conv6 = and i64 %mul3, 429496729536  %tobool = icmp ne i64 %conv6, %mul337  br i1 %tobool, label %lor.end, label %lor.rhs38 39lor.rhs:40  %and = and i64 %2, %mul341  %conv4 = trunc i64 %and to i3242  %tobool7 = icmp ne i32 %conv4, 043  %lnot = xor i1 %tobool7, true44  br label %lor.end45 46lor.end:47  %3 = phi i1 [ true, %entry ], [ %lnot, %lor.rhs ]48  %conv8 = zext i1 %3 to i3249  ret i32 %conv850}51 52; https://bugs.llvm.org/show_bug.cgi?id=3376553 54@glob = external global i1655 56define void @PR33765(i8 %beth) {57; CHECK-LABEL: @PR33765(58; CHECK-NEXT:    br i1 false, label [[IF_THEN9:%.*]], label [[IF_THEN9]]59; CHECK:       if.then9:60; CHECK-NEXT:    [[CONV:%.*]] = zext i8 [[BETH:%.*]] to i1661; CHECK-NEXT:    [[MUL:%.*]] = mul nuw i16 [[CONV]], [[CONV]]62; CHECK-NEXT:    [[TINKY:%.*]] = load i16, ptr @glob, align 263; CHECK-NEXT:    [[CONV14:%.*]] = and i16 [[MUL]], [[TINKY]]64; CHECK-NEXT:    store i16 [[CONV14]], ptr @glob, align 265; CHECK-NEXT:    ret void66;67  %conv = zext i8 %beth to i3268  %mul = mul nuw nsw i32 %conv, %conv69  %conv3 = and i32 %mul, 25570  %tobool8 = icmp ne i32 %mul, %conv371  br i1 %tobool8, label %if.then9, label %if.then972 73if.then9:74  %tinky = load i16, ptr @glob75  %conv13 = sext i16 %tinky to i3276  %and = and i32 %mul, %conv1377  %conv14 = trunc i32 %and to i1678  store i16 %conv14, ptr @glob79  ret void80}81 82; Repro case for bug involving mutating a list while83; iterating it.84 85declare i16 @aux(i8)86 87define i16 @iter_breaker(i16 %a, i16 %b) {88; CHECK-LABEL: @iter_breaker(89; CHECK-NEXT:    [[UMUL:%.*]] = call { i16, i1 } @llvm.umul.with.overflow.i16(i16 [[A:%.*]], i16 [[B:%.*]])90; CHECK-NEXT:    [[UMUL_VALUE:%.*]] = extractvalue { i16, i1 } [[UMUL]], 091; CHECK-NEXT:    [[DID_OVF:%.*]] = extractvalue { i16, i1 } [[UMUL]], 192; CHECK-NEXT:    br i1 [[DID_OVF]], label [[RET1:%.*]], label [[RET2:%.*]]93; CHECK:       ret1:94; CHECK-NEXT:    [[TRUNC_REMAIN:%.*]] = trunc i16 [[UMUL_VALUE]] to i895; CHECK-NEXT:    [[VAL:%.*]] = call i16 @aux(i8 [[TRUNC_REMAIN]])96; CHECK-NEXT:    ret i16 [[VAL]]97; CHECK:       ret2:98; CHECK-NEXT:    ret i16 [[UMUL_VALUE]]99;100  %a_wide = zext i16 %a to i32101  %b_wide = zext i16 %b to i32102  %mul_wide = mul i32 %a_wide, %b_wide              ; uses of %mul_wide will be iterated103 104  %trunc_remain = trunc i32 %mul_wide to i8         ; this use will be replaced w/ new value105  ; when iteration visits it, switching106  ; iteration to the uses of new value107 108  %trunc_unnecessary = trunc i32 %mul_wide to i16   ; uses of %trunc_unnecessary will have109  ; been updated to uses of new value110 111  %did_ovf = icmp ugt i32 %mul_wide, 65535112  br i1 %did_ovf, label %ret1, label %ret2113 114ret1:115  %val = call i16 @aux(i8 %trunc_remain)116  ret i16 %val117 118ret2:119  ret i16 %trunc_unnecessary              ; crash visiting this use after corrupting iterator120}121 122; This miscompiled because of broken pattern matching.123 124define i1 @PR46561(i1 %a, i1 %x, i1 %y, i8 %z) {125; CHECK-LABEL: @PR46561(126; CHECK-NEXT:  entry:127; CHECK-NEXT:    br i1 [[A:%.*]], label [[COND_TRUE:%.*]], label [[END:%.*]]128; CHECK:       cond.true:129; CHECK-NEXT:    [[MULBOOL:%.*]] = and i1 [[X:%.*]], [[Y:%.*]]130; CHECK-NEXT:    [[TMP0:%.*]] = trunc i8 [[Z:%.*]] to i1131; CHECK-NEXT:    [[TMP1:%.*]] = xor i1 [[MULBOOL]], [[TMP0]]132; CHECK-NEXT:    [[TMP2:%.*]] = xor i1 [[TMP1]], true133; CHECK-NEXT:    br label [[END]]134; CHECK:       end:135; CHECK-NEXT:    [[P:%.*]] = phi i1 [ [[TMP2]], [[COND_TRUE]] ], [ false, [[ENTRY:%.*]] ]136; CHECK-NEXT:    ret i1 [[P]]137;138entry:139  br i1 %a, label %cond.true, label %end140 141cond.true:142  %tz = trunc i8 %z to i1143  %zx = zext i1 %x to i32144  %zy = zext i1 %y to i32145  %zz = zext i1 %tz to i32146  %mul = mul i32 %zx, %zy147  %cond = xor i32 %mul, %zz148  br label %end149 150end:151  %p = phi i32 [ %cond, %cond.true ], [ -1, %entry ]152  %r = icmp eq i32 %p, 0153  ret i1 %r154}155