|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6 |
1 | 2 | ; RUN: opt < %s -passes=instcombine -S | FileCheck %s |
2 | 3 |
|
3 | | -define void @test (float %b, ptr %p) { |
4 | | -; CHECK: extractelement |
5 | | -; CHECK: fptosi |
6 | | - %1 = load <8 x float> , ptr %p |
| 4 | +define void @test_poison(float %b, ptr %p) { |
| 5 | +; CHECK-LABEL: define void @test_poison( |
| 6 | +; CHECK-SAME: float [[B:%.*]], ptr [[P:%.*]]) { |
| 7 | +; CHECK-NEXT: [[TMP1:%.*]] = load <8 x float>, ptr [[P]], align 32 |
| 8 | +; CHECK-NEXT: [[TMP2:%.*]] = fptosi float [[B]] to i32 |
| 9 | +; CHECK-NEXT: [[TMP3:%.*]] = add i32 [[TMP2]], -2 |
| 10 | +; CHECK-NEXT: [[TMP4:%.*]] = extractelement <8 x float> [[TMP1]], i32 [[TMP3]] |
| 11 | +; CHECK-NEXT: [[TMP5:%.*]] = fptosi float [[TMP4]] to i32 |
| 12 | +; CHECK-NEXT: [[TMP6:%.*]] = insertelement <8 x i32> poison, i32 [[TMP5]], i64 7 |
| 13 | +; CHECK-NEXT: [[TMP7:%.*]] = sitofp <8 x i32> [[TMP6]] to <8 x float> |
| 14 | +; CHECK-NEXT: store <8 x float> [[TMP7]], ptr [[P]], align 32 |
| 15 | +; CHECK-NEXT: ret void |
| 16 | +; |
| 17 | + %1 = load <8 x float>, ptr %p |
7 | 18 | %2 = bitcast <8 x float> %1 to <8 x i32> |
8 | 19 | %3 = bitcast <8 x i32> %2 to <8 x float> |
9 | 20 | %a = fptosi <8 x float> %3 to <8 x i32> |
10 | 21 | %4 = fptosi float %b to i32 |
11 | 22 | %5 = add i32 %4, -2 |
12 | 23 | %6 = extractelement <8 x i32> %a, i32 %5 |
13 | | - %7 = insertelement <8 x i32> undef, i32 %6, i32 7 |
| 24 | + %7 = insertelement <8 x i32> poison, i32 %6, i32 7 |
14 | 25 | %8 = sitofp <8 x i32> %7 to <8 x float> |
15 | 26 | store <8 x float> %8, ptr %p |
16 | | - ret void |
| 27 | + ret void |
17 | 28 | } |
18 | 29 |
|
19 | 30 | ; PR18600 |
20 | | -define i32 @test2(i32 %i) { |
| 31 | +define i32 @test_bitcast(i32 %i) { |
| 32 | +; CHECK-LABEL: define i32 @test_bitcast( |
| 33 | +; CHECK-SAME: i32 [[I:%.*]]) { |
| 34 | +; CHECK-NEXT: [[E:%.*]] = extractelement <4 x i32> <i32 1, i32 0, i32 2, i32 0>, i32 [[I]] |
| 35 | +; CHECK-NEXT: ret i32 [[E]] |
| 36 | +; |
21 | 37 | %e = extractelement <4 x i32> bitcast (<2 x i64> <i64 1, i64 2> to <4 x i32>), i32 %i |
22 | 38 | ret i32 %e |
| 39 | +} |
| 40 | + |
| 41 | +declare void @use(i32) |
23 | 42 |
|
24 | | -; CHECK-LABEL: @test2 |
25 | | -; CHECK: extractelement |
| 43 | +define void @test_loop(<4 x float> %in) { |
| 44 | +; CHECK-LABEL: define void @test_loop( |
| 45 | +; CHECK-SAME: <4 x float> [[IN:%.*]]) { |
| 46 | +; CHECK-NEXT: [[ENTRY:.*]]: |
| 47 | +; CHECK-NEXT: [[R:%.*]] = call <4 x float> @llvm.x86.sse41.round.ps(<4 x float> [[IN]], i32 9) |
| 48 | +; CHECK-NEXT: br label %[[LOOP:.*]] |
| 49 | +; CHECK: [[LOOP]]: |
| 50 | +; CHECK-NEXT: [[I:%.*]] = phi i32 [ 0, %[[ENTRY]] ], [ [[NEXT:%.*]], %[[LATCH:.*]] ] |
| 51 | +; CHECK-NEXT: [[COND:%.*]] = icmp samesign ult i32 [[I]], 4 |
| 52 | +; CHECK-NEXT: br i1 [[COND]], label %[[BODY:.*]], label %[[DONE:.*]] |
| 53 | +; CHECK: [[BODY]]: |
| 54 | +; CHECK-NEXT: [[TMP0:%.*]] = extractelement <4 x float> [[R]], i32 [[I]] |
| 55 | +; CHECK-NEXT: [[ELEM:%.*]] = fptosi float [[TMP0]] to i32 |
| 56 | +; CHECK-NEXT: call void @use(i32 [[ELEM]]) |
| 57 | +; CHECK-NEXT: br label %[[LATCH]] |
| 58 | +; CHECK: [[LATCH]]: |
| 59 | +; CHECK-NEXT: [[NEXT]] = add nuw nsw i32 [[I]], 1 |
| 60 | +; CHECK-NEXT: br label %[[LOOP]] |
| 61 | +; CHECK: [[DONE]]: |
| 62 | +; CHECK-NEXT: ret void |
| 63 | +; |
| 64 | +entry: |
| 65 | + %r = call <4 x float> @llvm.x86.sse41.round.ps(<4 x float> %in, i32 9) |
| 66 | + %vi = fptosi <4 x float> %r to <4 x i32> |
| 67 | + br label %loop |
| 68 | +loop: |
| 69 | + %i = phi i32 [ 0, %entry ], [ %next, %latch ] |
| 70 | + %cond = icmp ult i32 %i, 4 |
| 71 | + br i1 %cond, label %body, label %done |
| 72 | +body: |
| 73 | + %elem = extractelement <4 x i32> %vi, i32 %i |
| 74 | + call void @use(i32 %elem) |
| 75 | + br label %latch |
| 76 | +latch: |
| 77 | + %next = add i32 %i, 1 |
| 78 | + br label %loop |
| 79 | +done: |
| 80 | + ret void |
26 | 81 | } |
0 commit comments