|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 |
| 2 | +; RUN: opt -S -passes=gvn %s | FileCheck %s |
| 3 | + |
| 4 | +; NOTE: when we use a Token like type we should not introduce a phi |
| 5 | + |
| 6 | +@Out.str = private unnamed_addr constant [4 x i8] c"Out\00", align 1 |
| 7 | + |
| 8 | +define void @CSMain() local_unnamed_addr { |
| 9 | +; CHECK-LABEL: define void @CSMain() local_unnamed_addr { |
| 10 | +; CHECK-NEXT: [[ENTRY:.*:]] |
| 11 | +; CHECK-NEXT: [[TMP0:%.*]] = tail call i32 @llvm.dx.flattened.thread.id.in.group() |
| 12 | +; CHECK-NEXT: [[CMP_I1_NOT:%.*]] = icmp eq i32 [[TMP0]], 0 |
| 13 | +; CHECK-NEXT: br i1 [[CMP_I1_NOT]], label %[[CSMAIN_EXIT:.*]], label %[[FOR_BODY_I_LR_PH:.*]] |
| 14 | +; CHECK: [[FOR_BODY_I_LR_PH]]: |
| 15 | +; CHECK-NEXT: [[TMP1:%.*]] = tail call target("dx.RawBuffer", i32, 1, 0) @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_i32_1_0t(i32 0, i32 0, i32 4, i32 [[TMP0]], ptr nonnull @Out.str) |
| 16 | +; CHECK-NEXT: br label %[[FOR_BODY_I:.*]] |
| 17 | +; CHECK: [[FOR_BODY_I]]: |
| 18 | +; CHECK-NEXT: [[I_0_I2:%.*]] = phi i32 [ 0, %[[FOR_BODY_I_LR_PH]] ], [ [[INC_I:%.*]], %[[FOR_BODY_I]] ] |
| 19 | +; CHECK-NEXT: [[TMP2:%.*]] = tail call noundef i32 @llvm.dx.resource.updatecounter.tdx.RawBuffer_i32_1_0t(target("dx.RawBuffer", i32, 1, 0) [[TMP1]], i8 1) |
| 20 | +; CHECK-NEXT: [[INC_I]] = add nuw nsw i32 [[I_0_I2]], 1 |
| 21 | +; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i32 [[INC_I]], [[TMP0]] |
| 22 | +; CHECK-NEXT: br i1 [[EXITCOND]], label %[[FOR_BODY_I]], label %[[CSMAIN_EXIT_LOOPEXIT:.*]] |
| 23 | +; CHECK: [[CSMAIN_EXIT_LOOPEXIT]]: |
| 24 | +; CHECK-NEXT: br label %[[CSMAIN_EXIT]] |
| 25 | +; CHECK: [[CSMAIN_EXIT]]: |
| 26 | +; CHECK-NEXT: [[TMP3:%.*]] = tail call target("dx.RawBuffer", i32, 1, 0) @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_i32_1_0t(i32 0, i32 0, i32 4, i32 [[TMP0]], ptr nonnull @Out.str) |
| 27 | +; CHECK-NEXT: [[TMP4:%.*]] = tail call noundef i32 @llvm.dx.resource.updatecounter.tdx.RawBuffer_i32_1_0t(target("dx.RawBuffer", i32, 1, 0) [[TMP3]], i8 1) |
| 28 | +; CHECK-NEXT: [[TMP5:%.*]] = tail call noundef nonnull align 4 dereferenceable(4) ptr @llvm.dx.resource.getpointer.p0.tdx.RawBuffer_i32_1_0t(target("dx.RawBuffer", i32, 1, 0) [[TMP3]], i32 0) |
| 29 | +; CHECK-NEXT: store i32 [[TMP4]], ptr [[TMP5]], align 4 |
| 30 | +; CHECK-NEXT: ret void |
| 31 | +; |
| 32 | +entry: |
| 33 | + %0 = tail call i32 @llvm.dx.flattened.thread.id.in.group() |
| 34 | + %cmp.i1.not = icmp eq i32 %0, 0 |
| 35 | + br i1 %cmp.i1.not, label %CSMain.exit, label %for.body.i.lr.ph |
| 36 | + |
| 37 | +for.body.i.lr.ph: ; preds = %entry |
| 38 | + %1 = tail call target("dx.RawBuffer", i32, 1, 0) @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_i32_1_0t(i32 0, i32 0, i32 4, i32 %0, ptr nonnull @Out.str) |
| 39 | + br label %for.body.i |
| 40 | + |
| 41 | +for.body.i: ; preds = %for.body.i.lr.ph, %for.body.i |
| 42 | + %i.0.i2 = phi i32 [ 0, %for.body.i.lr.ph ], [ %inc.i, %for.body.i ] |
| 43 | + %2 = tail call noundef i32 @llvm.dx.resource.updatecounter.tdx.RawBuffer_i32_1_0t(target("dx.RawBuffer", i32, 1, 0) %1, i8 1) |
| 44 | + %inc.i = add nuw nsw i32 %i.0.i2, 1 |
| 45 | + %exitcond = icmp ne i32 %inc.i, %0 |
| 46 | + br i1 %exitcond, label %for.body.i, label %CSMain.exit.loopexit |
| 47 | + |
| 48 | +CSMain.exit.loopexit: ; preds = %for.body.i |
| 49 | + br label %CSMain.exit |
| 50 | + |
| 51 | +CSMain.exit: ; preds = %CSMain.exit.loopexit, %entry |
| 52 | + %3 = tail call target("dx.RawBuffer", i32, 1, 0) @llvm.dx.resource.handlefrombinding.tdx.RawBuffer_i32_1_0t(i32 0, i32 0, i32 4, i32 %0, ptr nonnull @Out.str) |
| 53 | + %4 = tail call noundef i32 @llvm.dx.resource.updatecounter.tdx.RawBuffer_i32_1_0t(target("dx.RawBuffer", i32, 1, 0) %3, i8 1) |
| 54 | + %5 = tail call noundef nonnull align 4 dereferenceable(4) ptr @llvm.dx.resource.getpointer.p0.tdx.RawBuffer_i32_1_0t(target("dx.RawBuffer", i32, 1, 0) %3, i32 0) |
| 55 | + store i32 %4, ptr %5, align 4 |
| 56 | + ret void |
| 57 | +} |
0 commit comments