Zvi Rackover | 38ba75c | 2017-03-31 07:46:02 +0000 | [diff] [blame] | 1 | ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py |
| 2 | ; RUN: opt < %s -instsimplify -S | FileCheck %s |
| 3 | |
Zvi Rackover | e479980 | 2017-04-02 10:42:21 +0000 | [diff] [blame] | 4 | define <4 x i32> @const_folding(<4 x i32> %x) { |
| 5 | ; CHECK-LABEL: @const_folding( |
Zvi Rackover | 8f46065 | 2017-04-03 22:05:30 +0000 | [diff] [blame] | 6 | ; CHECK-NEXT: ret <4 x i32> zeroinitializer |
Zvi Rackover | e479980 | 2017-04-02 10:42:21 +0000 | [diff] [blame] | 7 | ; |
| 8 | %shuf = shufflevector <4 x i32> %x, <4 x i32> zeroinitializer, <4 x i32> <i32 5, i32 4, i32 5, i32 4> |
| 9 | ret <4 x i32> %shuf |
| 10 | } |
| 11 | |
Zvi Rackover | 8f46065 | 2017-04-03 22:05:30 +0000 | [diff] [blame] | 12 | define <4 x i32> @const_folding1(<4 x i32> %x) { |
| 13 | ; CHECK-LABEL: @const_folding1( |
| 14 | ; CHECK-NEXT: ret <4 x i32> <i32 5, i32 5, i32 5, i32 5> |
| 15 | ; |
| 16 | %shuf = shufflevector <4 x i32> <i32 5, i32 4, i32 5, i32 4>, <4 x i32> %x, <4 x i32> zeroinitializer |
| 17 | ret <4 x i32> %shuf |
| 18 | } |
| 19 | |
| 20 | define <4 x i32> @const_folding_negative(<3 x i32> %x) { |
| 21 | ; CHECK-LABEL: @const_folding_negative( |
| 22 | ; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <3 x i32> [[X:%.*]], <3 x i32> zeroinitializer, <4 x i32> <i32 2, i32 4, i32 5, i32 4> |
| 23 | ; CHECK-NEXT: ret <4 x i32> [[SHUF]] |
| 24 | ; |
| 25 | %shuf = shufflevector <3 x i32> %x, <3 x i32> zeroinitializer, <4 x i32> <i32 2, i32 4, i32 5, i32 4> |
| 26 | ret <4 x i32> %shuf |
| 27 | } |
| 28 | |
Zvi Rackover | 38ba75c | 2017-03-31 07:46:02 +0000 | [diff] [blame] | 29 | define <4 x i32> @splat_operand(<4 x i32> %x) { |
| 30 | ; CHECK-LABEL: @splat_operand( |
| 31 | ; CHECK-NEXT: [[SPLAT:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> undef, <4 x i32> zeroinitializer |
| 32 | ; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i32> [[SPLAT]], <4 x i32> undef, <4 x i32> <i32 0, i32 3, i32 2, i32 1> |
| 33 | ; CHECK-NEXT: ret <4 x i32> [[SHUF]] |
| 34 | ; |
| 35 | %splat = shufflevector <4 x i32> %x, <4 x i32> undef, <4 x i32> zeroinitializer |
| 36 | %shuf = shufflevector <4 x i32> %splat, <4 x i32> undef, <4 x i32> <i32 0, i32 3, i32 2, i32 1> |
| 37 | ret <4 x i32> %shuf |
| 38 | } |
| 39 | |
| 40 | define <4 x i32> @undef_mask(<4 x i32> %x) { |
| 41 | ; CHECK-LABEL: @undef_mask( |
Zvi Rackover | 8f46065 | 2017-04-03 22:05:30 +0000 | [diff] [blame] | 42 | ; CHECK-NEXT: ret <4 x i32> undef |
Zvi Rackover | 38ba75c | 2017-03-31 07:46:02 +0000 | [diff] [blame] | 43 | ; |
| 44 | %shuf = shufflevector <4 x i32> %x, <4 x i32> undef, <4 x i32> undef |
| 45 | ret <4 x i32> %shuf |
| 46 | } |
| 47 | |
| 48 | define <4 x i32> @identity_mask_0(<4 x i32> %x) { |
| 49 | ; CHECK-LABEL: @identity_mask_0( |
| 50 | ; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3> |
| 51 | ; CHECK-NEXT: ret <4 x i32> [[SHUF]] |
| 52 | ; |
| 53 | %shuf = shufflevector <4 x i32> %x, <4 x i32> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 3> |
| 54 | ret <4 x i32> %shuf |
| 55 | } |
| 56 | |
| 57 | define <4 x i32> @identity_mask_1(<4 x i32> %x) { |
| 58 | ; CHECK-LABEL: @identity_mask_1( |
| 59 | ; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i32> undef, <4 x i32> [[X:%.*]], <4 x i32> <i32 4, i32 5, i32 6, i32 7> |
| 60 | ; CHECK-NEXT: ret <4 x i32> [[SHUF]] |
| 61 | ; |
| 62 | %shuf = shufflevector <4 x i32> undef, <4 x i32> %x, <4 x i32> <i32 4, i32 5, i32 6, i32 7> |
| 63 | ret <4 x i32> %shuf |
| 64 | } |
| 65 | |
| 66 | define <4 x i32> @pseudo_identity_mask(<4 x i32> %x) { |
| 67 | ; CHECK-LABEL: @pseudo_identity_mask( |
| 68 | ; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> [[X]], <4 x i32> <i32 0, i32 1, i32 2, i32 7> |
| 69 | ; CHECK-NEXT: ret <4 x i32> [[SHUF]] |
| 70 | ; |
| 71 | %shuf = shufflevector <4 x i32> %x, <4 x i32> %x, <4 x i32> <i32 0, i32 1, i32 2, i32 7> |
| 72 | ret <4 x i32> %shuf |
| 73 | } |
| 74 | |
| 75 | define <4 x i32> @const_operand(<4 x i32> %x) { |
| 76 | ; CHECK-LABEL: @const_operand( |
Zvi Rackover | 8f46065 | 2017-04-03 22:05:30 +0000 | [diff] [blame] | 77 | ; CHECK-NEXT: ret <4 x i32> <i32 42, i32 45, i32 44, i32 43> |
Zvi Rackover | 38ba75c | 2017-03-31 07:46:02 +0000 | [diff] [blame] | 78 | ; |
| 79 | %shuf = shufflevector <4 x i32> <i32 42, i32 43, i32 44, i32 45>, <4 x i32> %x, <4 x i32> <i32 0, i32 3, i32 2, i32 1> |
| 80 | ret <4 x i32> %shuf |
| 81 | } |
| 82 | |
| 83 | define <4 x i32> @merge(<4 x i32> %x) { |
| 84 | ; CHECK-LABEL: @merge( |
| 85 | ; CHECK-NEXT: [[LOWER:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> undef, <2 x i32> <i32 1, i32 0> |
| 86 | ; CHECK-NEXT: [[UPPER:%.*]] = shufflevector <4 x i32> [[X]], <4 x i32> undef, <2 x i32> <i32 2, i32 3> |
| 87 | ; CHECK-NEXT: [[MERGED:%.*]] = shufflevector <2 x i32> [[UPPER]], <2 x i32> [[LOWER]], <4 x i32> <i32 3, i32 2, i32 0, i32 1> |
| 88 | ; CHECK-NEXT: ret <4 x i32> [[MERGED]] |
| 89 | ; |
| 90 | %lower = shufflevector <4 x i32> %x, <4 x i32> undef, <2 x i32> <i32 1, i32 0> |
| 91 | %upper = shufflevector <4 x i32> %x, <4 x i32> undef, <2 x i32> <i32 2, i32 3> |
| 92 | %merged = shufflevector <2 x i32> %upper, <2 x i32> %lower, <4 x i32> <i32 3, i32 2, i32 0, i32 1> |
| 93 | ret <4 x i32> %merged |
| 94 | } |