Sanjay Patel | de3e889 | 2018-02-12 23:18:11 +0000 | [diff] [blame] | 1 | ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py |
| 2 | ; RUN: opt < %s -instsimplify -S | FileCheck %s |
| 3 | |
| 4 | declare double @llvm.log.f64(double) |
| 5 | declare double @llvm.exp.f64(double) |
Sanjay Patel | 246d7692 | 2018-02-12 23:51:23 +0000 | [diff] [blame] | 6 | declare double @llvm.log2.f64(double) |
| 7 | declare double @llvm.exp2.f64(double) |
Sanjay Patel | de3e889 | 2018-02-12 23:18:11 +0000 | [diff] [blame] | 8 | |
Sanjay Patel | 246d7692 | 2018-02-12 23:51:23 +0000 | [diff] [blame] | 9 | define double @log_reassoc_exp_strict(double %a) { |
| 10 | ; CHECK-LABEL: @log_reassoc_exp_strict( |
Sanjay Patel | c5d5933 | 2018-02-12 23:39:10 +0000 | [diff] [blame] | 11 | ; CHECK-NEXT: ret double [[A:%.*]] |
Sanjay Patel | de3e889 | 2018-02-12 23:18:11 +0000 | [diff] [blame] | 12 | ; |
| 13 | %1 = call double @llvm.exp.f64(double %a) |
Sanjay Patel | 246d7692 | 2018-02-12 23:51:23 +0000 | [diff] [blame] | 14 | %2 = call reassoc double @llvm.log.f64(double %1) |
Sanjay Patel | de3e889 | 2018-02-12 23:18:11 +0000 | [diff] [blame] | 15 | ret double %2 |
| 16 | } |
| 17 | |
Sanjay Patel | 246d7692 | 2018-02-12 23:51:23 +0000 | [diff] [blame] | 18 | define double @log_strict_exp_reassoc(double %a) { |
| 19 | ; CHECK-LABEL: @log_strict_exp_reassoc( |
| 20 | ; CHECK-NEXT: [[TMP1:%.*]] = call reassoc double @llvm.exp.f64(double [[A:%.*]]) |
Sanjay Patel | de3e889 | 2018-02-12 23:18:11 +0000 | [diff] [blame] | 21 | ; CHECK-NEXT: [[TMP2:%.*]] = call double @llvm.log.f64(double [[TMP1]]) |
| 22 | ; CHECK-NEXT: ret double [[TMP2]] |
| 23 | ; |
Sanjay Patel | 246d7692 | 2018-02-12 23:51:23 +0000 | [diff] [blame] | 24 | %1 = call reassoc double @llvm.exp.f64(double %a) |
Sanjay Patel | de3e889 | 2018-02-12 23:18:11 +0000 | [diff] [blame] | 25 | %2 = call double @llvm.log.f64(double %1) |
| 26 | ret double %2 |
| 27 | } |
| 28 | |
| 29 | define double @log_exp_log_exp(double %a) { |
| 30 | ; CHECK-LABEL: @log_exp_log_exp( |
| 31 | ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.exp.f64(double [[A:%.*]]) |
| 32 | ; CHECK-NEXT: [[TMP2:%.*]] = call double @llvm.log.f64(double [[TMP1]]) |
| 33 | ; CHECK-NEXT: [[TMP3:%.*]] = call double @llvm.exp.f64(double [[TMP2]]) |
| 34 | ; CHECK-NEXT: [[TMP4:%.*]] = call double @llvm.log.f64(double [[TMP3]]) |
| 35 | ; CHECK-NEXT: ret double [[TMP4]] |
| 36 | ; |
| 37 | %1 = call double @llvm.exp.f64(double %a) |
| 38 | %2 = call double @llvm.log.f64(double %1) |
| 39 | %3 = call double @llvm.exp.f64(double %2) |
| 40 | %4 = call double @llvm.log.f64(double %3) |
| 41 | ret double %4 |
| 42 | } |
| 43 | |
Sanjay Patel | 246d7692 | 2018-02-12 23:51:23 +0000 | [diff] [blame] | 44 | define double @log_exp_log_exp_reassoc(double %a) { |
| 45 | ; CHECK-LABEL: @log_exp_log_exp_reassoc( |
Sanjay Patel | c5d5933 | 2018-02-12 23:39:10 +0000 | [diff] [blame] | 46 | ; CHECK-NEXT: ret double [[A:%.*]] |
Sanjay Patel | de3e889 | 2018-02-12 23:18:11 +0000 | [diff] [blame] | 47 | ; |
| 48 | %1 = call double @llvm.exp.f64(double %a) |
Sanjay Patel | 246d7692 | 2018-02-12 23:51:23 +0000 | [diff] [blame] | 49 | %2 = call reassoc double @llvm.log.f64(double %1) |
Sanjay Patel | de3e889 | 2018-02-12 23:18:11 +0000 | [diff] [blame] | 50 | %3 = call double @llvm.exp.f64(double %2) |
Sanjay Patel | 246d7692 | 2018-02-12 23:51:23 +0000 | [diff] [blame] | 51 | %4 = call reassoc double @llvm.log.f64(double %3) |
Sanjay Patel | de3e889 | 2018-02-12 23:18:11 +0000 | [diff] [blame] | 52 | ret double %4 |
| 53 | } |
| 54 | |
Sanjay Patel | 246d7692 | 2018-02-12 23:51:23 +0000 | [diff] [blame] | 55 | define double @log2_reassoc_exp2_strict(double %a) { |
| 56 | ; CHECK-LABEL: @log2_reassoc_exp2_strict( |
Sanjay Patel | c5d5933 | 2018-02-12 23:39:10 +0000 | [diff] [blame] | 57 | ; CHECK-NEXT: ret double [[A:%.*]] |
Sanjay Patel | de3e889 | 2018-02-12 23:18:11 +0000 | [diff] [blame] | 58 | ; |
| 59 | %1 = call double @llvm.exp2.f64(double %a) |
Sanjay Patel | 246d7692 | 2018-02-12 23:51:23 +0000 | [diff] [blame] | 60 | %2 = call reassoc double @llvm.log2.f64(double %1) |
Sanjay Patel | de3e889 | 2018-02-12 23:18:11 +0000 | [diff] [blame] | 61 | ret double %2 |
| 62 | } |
| 63 | |
Sanjay Patel | 246d7692 | 2018-02-12 23:51:23 +0000 | [diff] [blame] | 64 | define double @log2_strict_exp2_reassoc(double %a) { |
| 65 | ; CHECK-LABEL: @log2_strict_exp2_reassoc( |
| 66 | ; CHECK-NEXT: [[TMP1:%.*]] = call reassoc double @llvm.exp2.f64(double [[A:%.*]]) |
Sanjay Patel | de3e889 | 2018-02-12 23:18:11 +0000 | [diff] [blame] | 67 | ; CHECK-NEXT: [[TMP2:%.*]] = call double @llvm.log2.f64(double [[TMP1]]) |
| 68 | ; CHECK-NEXT: ret double [[TMP2]] |
| 69 | ; |
Sanjay Patel | 246d7692 | 2018-02-12 23:51:23 +0000 | [diff] [blame] | 70 | %1 = call reassoc double @llvm.exp2.f64(double %a) |
Sanjay Patel | de3e889 | 2018-02-12 23:18:11 +0000 | [diff] [blame] | 71 | %2 = call double @llvm.log2.f64(double %1) |
| 72 | ret double %2 |
| 73 | } |
| 74 | |
| 75 | define double @log2_exp2_log2_exp2(double %a) { |
| 76 | ; CHECK-LABEL: @log2_exp2_log2_exp2( |
| 77 | ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.exp2.f64(double [[A:%.*]]) |
| 78 | ; CHECK-NEXT: [[TMP2:%.*]] = call double @llvm.log2.f64(double [[TMP1]]) |
| 79 | ; CHECK-NEXT: [[TMP3:%.*]] = call double @llvm.exp2.f64(double [[TMP2]]) |
| 80 | ; CHECK-NEXT: [[TMP4:%.*]] = call double @llvm.log2.f64(double [[TMP3]]) |
| 81 | ; CHECK-NEXT: ret double [[TMP4]] |
| 82 | ; |
| 83 | %1 = call double @llvm.exp2.f64(double %a) |
| 84 | %2 = call double @llvm.log2.f64(double %1) |
| 85 | %3 = call double @llvm.exp2.f64(double %2) |
| 86 | %4 = call double @llvm.log2.f64(double %3) |
| 87 | ret double %4 |
| 88 | } |
| 89 | |
Sanjay Patel | 246d7692 | 2018-02-12 23:51:23 +0000 | [diff] [blame] | 90 | define double @log2_exp2_log2_exp2_reassoc(double %a) { |
| 91 | ; CHECK-LABEL: @log2_exp2_log2_exp2_reassoc( |
Sanjay Patel | c5d5933 | 2018-02-12 23:39:10 +0000 | [diff] [blame] | 92 | ; CHECK-NEXT: ret double [[A:%.*]] |
Sanjay Patel | de3e889 | 2018-02-12 23:18:11 +0000 | [diff] [blame] | 93 | ; |
| 94 | %1 = call double @llvm.exp2.f64(double %a) |
Sanjay Patel | 246d7692 | 2018-02-12 23:51:23 +0000 | [diff] [blame] | 95 | %2 = call reassoc double @llvm.log2.f64(double %1) |
Sanjay Patel | de3e889 | 2018-02-12 23:18:11 +0000 | [diff] [blame] | 96 | %3 = call double @llvm.exp2.f64(double %2) |
Sanjay Patel | 246d7692 | 2018-02-12 23:51:23 +0000 | [diff] [blame] | 97 | %4 = call reassoc double @llvm.log2.f64(double %3) |
Sanjay Patel | de3e889 | 2018-02-12 23:18:11 +0000 | [diff] [blame] | 98 | ret double %4 |
| 99 | } |
| 100 | |
Sanjay Patel | 246d7692 | 2018-02-12 23:51:23 +0000 | [diff] [blame] | 101 | define double @exp_reassoc_log_strict(double %a) { |
| 102 | ; CHECK-LABEL: @exp_reassoc_log_strict( |
Sanjay Patel | c5d5933 | 2018-02-12 23:39:10 +0000 | [diff] [blame] | 103 | ; CHECK-NEXT: ret double [[A:%.*]] |
Sanjay Patel | de3e889 | 2018-02-12 23:18:11 +0000 | [diff] [blame] | 104 | ; |
| 105 | %1 = call double @llvm.log.f64(double %a) |
Sanjay Patel | 246d7692 | 2018-02-12 23:51:23 +0000 | [diff] [blame] | 106 | %2 = call reassoc double @llvm.exp.f64(double %1) |
Sanjay Patel | de3e889 | 2018-02-12 23:18:11 +0000 | [diff] [blame] | 107 | ret double %2 |
| 108 | } |
| 109 | |
Sanjay Patel | 246d7692 | 2018-02-12 23:51:23 +0000 | [diff] [blame] | 110 | define double @exp_strict_log_reassoc(double %a) { |
| 111 | ; CHECK-LABEL: @exp_strict_log_reassoc( |
| 112 | ; CHECK-NEXT: [[TMP1:%.*]] = call reassoc double @llvm.log.f64(double [[A:%.*]]) |
Sanjay Patel | de3e889 | 2018-02-12 23:18:11 +0000 | [diff] [blame] | 113 | ; CHECK-NEXT: [[TMP2:%.*]] = call double @llvm.exp.f64(double [[TMP1]]) |
| 114 | ; CHECK-NEXT: ret double [[TMP2]] |
| 115 | ; |
Sanjay Patel | 246d7692 | 2018-02-12 23:51:23 +0000 | [diff] [blame] | 116 | %1 = call reassoc double @llvm.log.f64(double %a) |
Sanjay Patel | de3e889 | 2018-02-12 23:18:11 +0000 | [diff] [blame] | 117 | %2 = call double @llvm.exp.f64(double %1) |
| 118 | ret double %2 |
| 119 | } |
| 120 | |
| 121 | define double @exp_log_exp_log(double %a) { |
| 122 | ; CHECK-LABEL: @exp_log_exp_log( |
| 123 | ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.log.f64(double [[A:%.*]]) |
| 124 | ; CHECK-NEXT: [[TMP2:%.*]] = call double @llvm.exp.f64(double [[TMP1]]) |
| 125 | ; CHECK-NEXT: [[TMP3:%.*]] = call double @llvm.log.f64(double [[TMP2]]) |
| 126 | ; CHECK-NEXT: [[TMP4:%.*]] = call double @llvm.exp.f64(double [[TMP3]]) |
| 127 | ; CHECK-NEXT: ret double [[TMP4]] |
| 128 | ; |
| 129 | %1 = call double @llvm.log.f64(double %a) |
| 130 | %2 = call double @llvm.exp.f64(double %1) |
| 131 | %3 = call double @llvm.log.f64(double %2) |
| 132 | %4 = call double @llvm.exp.f64(double %3) |
| 133 | ret double %4 |
| 134 | } |
| 135 | |
Sanjay Patel | 246d7692 | 2018-02-12 23:51:23 +0000 | [diff] [blame] | 136 | define double @exp_log_exp_log_reassoc(double %a) { |
| 137 | ; CHECK-LABEL: @exp_log_exp_log_reassoc( |
Sanjay Patel | c5d5933 | 2018-02-12 23:39:10 +0000 | [diff] [blame] | 138 | ; CHECK-NEXT: ret double [[A:%.*]] |
Sanjay Patel | de3e889 | 2018-02-12 23:18:11 +0000 | [diff] [blame] | 139 | ; |
| 140 | %1 = call double @llvm.log.f64(double %a) |
Sanjay Patel | 246d7692 | 2018-02-12 23:51:23 +0000 | [diff] [blame] | 141 | %2 = call reassoc double @llvm.exp.f64(double %1) |
Sanjay Patel | de3e889 | 2018-02-12 23:18:11 +0000 | [diff] [blame] | 142 | %3 = call double @llvm.log.f64(double %2) |
Sanjay Patel | 246d7692 | 2018-02-12 23:51:23 +0000 | [diff] [blame] | 143 | %4 = call reassoc double @llvm.exp.f64(double %3) |
Sanjay Patel | de3e889 | 2018-02-12 23:18:11 +0000 | [diff] [blame] | 144 | ret double %4 |
| 145 | } |
| 146 | |
Sanjay Patel | 246d7692 | 2018-02-12 23:51:23 +0000 | [diff] [blame] | 147 | define double @exp2_reassoc_log2_strict(double %a) { |
| 148 | ; CHECK-LABEL: @exp2_reassoc_log2_strict( |
Sanjay Patel | c5d5933 | 2018-02-12 23:39:10 +0000 | [diff] [blame] | 149 | ; CHECK-NEXT: ret double [[A:%.*]] |
Sanjay Patel | de3e889 | 2018-02-12 23:18:11 +0000 | [diff] [blame] | 150 | ; |
| 151 | %1 = call double @llvm.log2.f64(double %a) |
Sanjay Patel | 246d7692 | 2018-02-12 23:51:23 +0000 | [diff] [blame] | 152 | %2 = call reassoc double @llvm.exp2.f64(double %1) |
Sanjay Patel | de3e889 | 2018-02-12 23:18:11 +0000 | [diff] [blame] | 153 | ret double %2 |
| 154 | } |
| 155 | |
Sanjay Patel | 246d7692 | 2018-02-12 23:51:23 +0000 | [diff] [blame] | 156 | define double @exp2_strict_log2_reassoc(double %a) { |
| 157 | ; CHECK-LABEL: @exp2_strict_log2_reassoc( |
| 158 | ; CHECK-NEXT: [[TMP1:%.*]] = call reassoc double @llvm.log2.f64(double [[A:%.*]]) |
Sanjay Patel | de3e889 | 2018-02-12 23:18:11 +0000 | [diff] [blame] | 159 | ; CHECK-NEXT: [[TMP2:%.*]] = call double @llvm.exp2.f64(double [[TMP1]]) |
| 160 | ; CHECK-NEXT: ret double [[TMP2]] |
| 161 | ; |
Sanjay Patel | 246d7692 | 2018-02-12 23:51:23 +0000 | [diff] [blame] | 162 | %1 = call reassoc double @llvm.log2.f64(double %a) |
Sanjay Patel | de3e889 | 2018-02-12 23:18:11 +0000 | [diff] [blame] | 163 | %2 = call double @llvm.exp2.f64(double %1) |
| 164 | ret double %2 |
| 165 | } |
| 166 | |
| 167 | define double @exp2_log2_exp2_log2(double %a) { |
| 168 | ; CHECK-LABEL: @exp2_log2_exp2_log2( |
| 169 | ; CHECK-NEXT: [[TMP1:%.*]] = call double @llvm.log2.f64(double [[A:%.*]]) |
| 170 | ; CHECK-NEXT: [[TMP2:%.*]] = call double @llvm.exp2.f64(double [[TMP1]]) |
| 171 | ; CHECK-NEXT: [[TMP3:%.*]] = call double @llvm.log2.f64(double [[TMP2]]) |
| 172 | ; CHECK-NEXT: [[TMP4:%.*]] = call double @llvm.exp2.f64(double [[TMP3]]) |
| 173 | ; CHECK-NEXT: ret double [[TMP4]] |
| 174 | ; |
| 175 | %1 = call double @llvm.log2.f64(double %a) |
| 176 | %2 = call double @llvm.exp2.f64(double %1) |
| 177 | %3 = call double @llvm.log2.f64(double %2) |
| 178 | %4 = call double @llvm.exp2.f64(double %3) |
| 179 | ret double %4 |
| 180 | } |
| 181 | |
Sanjay Patel | 246d7692 | 2018-02-12 23:51:23 +0000 | [diff] [blame] | 182 | define double @exp2_log2_exp2_log2_reassoc(double %a) { |
| 183 | ; CHECK-LABEL: @exp2_log2_exp2_log2_reassoc( |
Sanjay Patel | c5d5933 | 2018-02-12 23:39:10 +0000 | [diff] [blame] | 184 | ; CHECK-NEXT: ret double [[A:%.*]] |
Sanjay Patel | de3e889 | 2018-02-12 23:18:11 +0000 | [diff] [blame] | 185 | ; |
| 186 | %1 = call double @llvm.log2.f64(double %a) |
Sanjay Patel | 246d7692 | 2018-02-12 23:51:23 +0000 | [diff] [blame] | 187 | %2 = call reassoc double @llvm.exp2.f64(double %1) |
Sanjay Patel | de3e889 | 2018-02-12 23:18:11 +0000 | [diff] [blame] | 188 | %3 = call double @llvm.log2.f64(double %2) |
Sanjay Patel | 246d7692 | 2018-02-12 23:51:23 +0000 | [diff] [blame] | 189 | %4 = call reassoc double @llvm.exp2.f64(double %3) |
Sanjay Patel | de3e889 | 2018-02-12 23:18:11 +0000 | [diff] [blame] | 190 | ret double %4 |
| 191 | } |
| 192 | |