diff options
author | Sanjay Patel <spatel@rotateright.com> | 2018-03-02 19:26:13 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2018-03-02 19:26:13 +0000 |
commit | bb7228703af46e5e8f30f45368873062a905302b (patch) | |
tree | bdd11878bf256d64e311f4775040bb195920da6a /llvm | |
parent | ada5234b6ee64579ef42f0e5a7df10d335235acb (diff) | |
download | bcm5719-llvm-bb7228703af46e5e8f30f45368873062a905302b.tar.gz bcm5719-llvm-bb7228703af46e5e8f30f45368873062a905302b.zip |
[InstCombine] add tests for rL169025; NFC
This narrow fold was added with no motivation or test cases
a bit over 5 years ago. Removing a constant operand is a
good canonicalization? We should handle Y*2.0 too then?
llvm-svn: 326606
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/test/Transforms/InstCombine/fmul.ll | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/fmul.ll b/llvm/test/Transforms/InstCombine/fmul.ll index b46897c3830..a1c0ae12153 100644 --- a/llvm/test/Transforms/InstCombine/fmul.ll +++ b/llvm/test/Transforms/InstCombine/fmul.ll @@ -300,3 +300,35 @@ define float @reassoc_common_operand_multi_use(float %x, float %y) { ret float %mul2 } +declare float @llvm.log2.f32(float) + +; X * log2(Y * 0.5) = X * log2(Y) - X + +define float @log2half(float %x, float %y) { +; CHECK-LABEL: @log2half( +; CHECK-NEXT: [[LOG2:%.*]] = call fast float @llvm.log2.f32(float [[Y:%.*]]) +; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[LOG2]], [[X:%.*]] +; CHECK-NEXT: [[MUL:%.*]] = fsub fast float [[TMP1]], [[X]] +; CHECK-NEXT: ret float [[MUL]] +; + %halfy = fmul fast float %y, 0.5 + %log2 = call fast float @llvm.log2.f32(float %halfy) + %mul = fmul fast float %log2, %x + ret float %mul +} + +define float @log2half_commute(float %x1, float %y) { +; CHECK-LABEL: @log2half_commute( +; CHECK-NEXT: [[X:%.*]] = fdiv float [[X1:%.*]], 7.000000e+00 +; CHECK-NEXT: [[LOG2:%.*]] = call fast float @llvm.log2.f32(float [[Y:%.*]]) +; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[X]], [[LOG2]] +; CHECK-NEXT: [[MUL:%.*]] = fsub fast float [[TMP1]], [[X]] +; CHECK-NEXT: ret float [[MUL]] +; + %x = fdiv float %x1, 7.0 ; thwart complexity-based canonicalization + %halfy = fmul fast float %y, 0.5 + %log2 = call fast float @llvm.log2.f32(float %halfy) + %mul = fmul fast float %x, %log2 + ret float %mul +} + |