brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.2 KiB · ef2df8a Raw
130 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 42; RUN: opt < %s -passes=div-rem-pairs -S -mtriple=amdgcn-amd-amdhsa | FileCheck %s3 4define i32 @basic(ptr %p, i32 %x, i32 %y) {5; CHECK-LABEL: define i32 @basic(6; CHECK-SAME: ptr [[P:%.*]], i32 [[X:%.*]], i32 [[Y:%.*]]) {7; CHECK-NEXT:    [[X_FROZEN:%.*]] = freeze i32 [[X]]8; CHECK-NEXT:    [[Y_FROZEN:%.*]] = freeze i32 [[Y]]9; CHECK-NEXT:    [[DIV:%.*]] = udiv i32 [[X_FROZEN]], [[Y_FROZEN]]10; CHECK-NEXT:    [[TMP1:%.*]] = mul i32 [[DIV]], [[Y_FROZEN]]11; CHECK-NEXT:    [[REM_DECOMPOSED:%.*]] = sub i32 [[X_FROZEN]], [[TMP1]]12; CHECK-NEXT:    store i32 [[DIV]], ptr [[P]], align 413; CHECK-NEXT:    ret i32 [[REM_DECOMPOSED]]14;15  %div = udiv i32 %x, %y16  %rem = urem i32 %x, %y17  store i32 %div, ptr %p, align 418  ret i32 %rem19}20 21define i32 @no_freezes(ptr %p, i32 noundef %x, i32 noundef %y) {22; CHECK-LABEL: define i32 @no_freezes(23; CHECK-SAME: ptr [[P:%.*]], i32 noundef [[X:%.*]], i32 noundef [[Y:%.*]]) {24; CHECK-NEXT:    [[DIV:%.*]] = udiv i32 [[X]], [[Y]]25; CHECK-NEXT:    [[TMP1:%.*]] = mul i32 [[DIV]], [[Y]]26; CHECK-NEXT:    [[REM_DECOMPOSED:%.*]] = sub i32 [[X]], [[TMP1]]27; CHECK-NEXT:    store i32 [[DIV]], ptr [[P]], align 428; CHECK-NEXT:    ret i32 [[REM_DECOMPOSED]]29;30  %div = udiv i32 %x, %y31  %rem = urem i32 %x, %y32  store i32 %div, ptr %p, align 433  ret i32 %rem34}35 36define i32 @poison_does_not_freeze(ptr %p, i32 noundef %x, i32 noundef %y) {37; CHECK-LABEL: define i32 @poison_does_not_freeze(38; CHECK-SAME: ptr [[P:%.*]], i32 noundef [[X:%.*]], i32 noundef [[Y:%.*]]) {39; CHECK-NEXT:    [[X2:%.*]] = shl nuw nsw i32 [[X]], 540; CHECK-NEXT:    [[Y2:%.*]] = add nuw nsw i32 [[Y]], 141; CHECK-NEXT:    [[DIV:%.*]] = udiv i32 [[X2]], [[Y2]]42; CHECK-NEXT:    [[TMP1:%.*]] = mul i32 [[DIV]], [[Y2]]43; CHECK-NEXT:    [[REM_DECOMPOSED:%.*]] = sub i32 [[X2]], [[TMP1]]44; CHECK-NEXT:    store i32 [[DIV]], ptr [[P]], align 445; CHECK-NEXT:    ret i32 [[REM_DECOMPOSED]]46;47  %x2 = shl nuw nsw i32 %x, 548  %y2 = add nuw nsw i32 %y, 149  %div = udiv i32 %x2, %y250  %rem = urem i32 %x2, %y251  store i32 %div, ptr %p, align 452  ret i32 %rem53}54 55define i32 @poison_does_not_freeze_signed(ptr %p, i32 noundef %x, i32 noundef %y) {56; CHECK-LABEL: define i32 @poison_does_not_freeze_signed(57; CHECK-SAME: ptr [[P:%.*]], i32 noundef [[X:%.*]], i32 noundef [[Y:%.*]]) {58; CHECK-NEXT:    [[X2:%.*]] = shl nuw nsw i32 [[X]], 559; CHECK-NEXT:    [[Y2:%.*]] = add nuw nsw i32 [[Y]], 160; CHECK-NEXT:    [[DIV:%.*]] = sdiv i32 [[X2]], [[Y2]]61; CHECK-NEXT:    [[TMP1:%.*]] = mul i32 [[DIV]], [[Y2]]62; CHECK-NEXT:    [[REM_DECOMPOSED:%.*]] = sub i32 [[X2]], [[TMP1]]63; CHECK-NEXT:    store i32 [[DIV]], ptr [[P]], align 464; CHECK-NEXT:    ret i32 [[REM_DECOMPOSED]]65;66  %x2 = shl nuw nsw i32 %x, 567  %y2 = add nuw nsw i32 %y, 168  %div = sdiv i32 %x2, %y269  %rem = srem i32 %x2, %y270  store i32 %div, ptr %p, align 471  ret i32 %rem72}73 74define <4 x i8> @poison_does_not_freeze_vector(ptr %p, <4 x i8> noundef %x, <4 x i8> noundef %y) {75; CHECK-LABEL: define <4 x i8> @poison_does_not_freeze_vector(76; CHECK-SAME: ptr [[P:%.*]], <4 x i8> noundef [[X:%.*]], <4 x i8> noundef [[Y:%.*]]) {77; CHECK-NEXT:    [[X2:%.*]] = shl nuw nsw <4 x i8> [[X]], splat (i8 5)78; CHECK-NEXT:    [[Y2:%.*]] = add nuw nsw <4 x i8> [[Y]], splat (i8 1)79; CHECK-NEXT:    [[DIV:%.*]] = udiv <4 x i8> [[X2]], [[Y2]]80; CHECK-NEXT:    [[TMP1:%.*]] = mul <4 x i8> [[DIV]], [[Y2]]81; CHECK-NEXT:    [[REM_DECOMPOSED:%.*]] = sub <4 x i8> [[X2]], [[TMP1]]82; CHECK-NEXT:    store <4 x i8> [[DIV]], ptr [[P]], align 483; CHECK-NEXT:    ret <4 x i8> [[REM_DECOMPOSED]]84;85  %x2 = shl nuw nsw <4 x i8> %x, <i8 5, i8 5, i8 5, i8 5>86  %y2 = add nuw nsw <4 x i8> %y, <i8 1, i8 1, i8 1, i8 1>87  %div = udiv <4 x i8> %x2, %y288  %rem = urem <4 x i8> %x2, %y289  store <4 x i8> %div, ptr %p, align 490  ret <4 x i8> %rem91}92 93define i32 @explicit_poison_does_not_freeze(ptr %p, i32 noundef %y) {94; CHECK-LABEL: define i32 @explicit_poison_does_not_freeze(95; CHECK-SAME: ptr [[P:%.*]], i32 noundef [[Y:%.*]]) {96; CHECK-NEXT:    [[X:%.*]] = add i32 poison, 197; CHECK-NEXT:    [[Y2:%.*]] = add nuw nsw i32 [[Y]], 198; CHECK-NEXT:    [[DIV:%.*]] = udiv i32 [[X]], [[Y2]]99; CHECK-NEXT:    [[TMP1:%.*]] = mul i32 [[DIV]], [[Y2]]100; CHECK-NEXT:    [[REM_DECOMPOSED:%.*]] = sub i32 [[X]], [[TMP1]]101; CHECK-NEXT:    store i32 [[DIV]], ptr [[P]], align 4102; CHECK-NEXT:    ret i32 [[REM_DECOMPOSED]]103;104  %x = add i32 poison, 1105  %y2 = add nuw nsw i32 %y, 1106  %div = udiv i32 %x, %y2107  %rem = urem i32 %x, %y2108  store i32 %div, ptr %p, align 4109  ret i32 %rem110}111 112define i32 @explicit_poison_does_not_freeze_signed(ptr %p, i32 noundef %y) {113; CHECK-LABEL: define i32 @explicit_poison_does_not_freeze_signed(114; CHECK-SAME: ptr [[P:%.*]], i32 noundef [[Y:%.*]]) {115; CHECK-NEXT:    [[X:%.*]] = add i32 poison, 1116; CHECK-NEXT:    [[Y2:%.*]] = add nuw nsw i32 [[Y]], 1117; CHECK-NEXT:    [[DIV:%.*]] = sdiv i32 [[X]], [[Y2]]118; CHECK-NEXT:    [[TMP1:%.*]] = mul i32 [[DIV]], [[Y2]]119; CHECK-NEXT:    [[REM_DECOMPOSED:%.*]] = sub i32 [[X]], [[TMP1]]120; CHECK-NEXT:    store i32 [[DIV]], ptr [[P]], align 4121; CHECK-NEXT:    ret i32 [[REM_DECOMPOSED]]122;123  %x = add i32 poison, 1124  %y2 = add nuw nsw i32 %y, 1125  %div = sdiv i32 %x, %y2126  %rem = srem i32 %x, %y2127  store i32 %div, ptr %p, align 4128  ret i32 %rem129}130