From: Sanjay Patel Date: Thu, 27 Sep 2018 14:24:29 +0000 (+0000) Subject: [InstCombine] add tests for FP sign-bit cmp optimization with fdiv; NFC X-Git-Tag: llvmorg-8.0.0-rc1~7773 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=95a816b34aa52a35a3bc0064e2ef797b60e47c6a;p=platform%2Fupstream%2Fllvm.git [InstCombine] add tests for FP sign-bit cmp optimization with fdiv; NFC These are baseline tests for D51942. Patch by: @marels (Martin Elshuber) llvm-svn: 343222 --- diff --git a/llvm/test/Transforms/InstCombine/fcmp.ll b/llvm/test/Transforms/InstCombine/fcmp.ll index 96537dc..a71c6e5 100644 --- a/llvm/test/Transforms/InstCombine/fcmp.ll +++ b/llvm/test/Transforms/InstCombine/fcmp.ll @@ -377,3 +377,99 @@ define i1 @test19_undef_ordered() { ret i1 %cmp } +; Can fold 1.0 / X < 0.0 --> X < 0 with ninf +define i1 @test20_recipX_olt_0(float %X) { +; CHECK-LABEL: @test20_recipX_olt_0( +; CHECK-NEXT: [[DIV:%.*]] = fdiv ninf float 1.000000e+00, [[X:%.*]] +; CHECK-NEXT: [[CMP:%.*]] = fcmp ninf olt float [[DIV]], 0.000000e+00 +; CHECK-NEXT: ret i1 [[CMP]] +; + %div = fdiv ninf float 1.0, %X + %cmp = fcmp ninf olt float %div, 0.0 + ret i1 %cmp +} + +; Can fold -2.0 / X <= 0.0 --> X >= 0 with ninf +define i1 @test21_recipX_ole_0(float %X) { +; CHECK-LABEL: @test21_recipX_ole_0( +; CHECK-NEXT: [[DIV:%.*]] = fdiv ninf float -2.000000e+00, [[X:%.*]] +; CHECK-NEXT: [[CMP:%.*]] = fcmp ninf ole float [[DIV]], 0.000000e+00 +; CHECK-NEXT: ret i1 [[CMP]] +; + %div = fdiv ninf float -2.0, %X + %cmp = fcmp ninf ole float %div, 0.0 + ret i1 %cmp +} + +; Can fold 2.0 / X > 0.0 --> X > 0 with ninf +define i1 @test22_recipX_ogt_0(float %X) { +; CHECK-LABEL: @test22_recipX_ogt_0( +; CHECK-NEXT: [[DIV:%.*]] = fdiv ninf float 2.000000e+00, [[X:%.*]] +; CHECK-NEXT: [[CMP:%.*]] = fcmp ninf ogt float [[DIV]], 0.000000e+00 +; CHECK-NEXT: ret i1 [[CMP]] +; + %div = fdiv ninf float 2.0, %X + %cmp = fcmp ninf ogt float %div, 0.0 + ret i1 %cmp +} + +; Can fold -1.0 / X >= 0.0 --> X <= 0 with ninf +define i1 @test23_recipX_oge_0(float %X) { +; CHECK-LABEL: @test23_recipX_oge_0( +; CHECK-NEXT: [[DIV:%.*]] = fdiv ninf float -1.000000e+00, [[X:%.*]] +; CHECK-NEXT: [[CMP:%.*]] = fcmp ninf oge float [[DIV]], 0.000000e+00 +; CHECK-NEXT: ret i1 [[CMP]] +; + %div = fdiv ninf float -1.0, %X + %cmp = fcmp ninf oge float %div, 0.0 + ret i1 %cmp +} + +; Do not fold 1.0 / X > 0.0 when ninf is missing +define i1 @test24_recipX_noninf_cmp(float %X) { +; CHECK-LABEL: @test24_recipX_noninf_cmp( +; CHECK-NEXT: [[DIV:%.*]] = fdiv ninf float 2.000000e+00, [[X:%.*]] +; CHECK-NEXT: [[CMP:%.*]] = fcmp ogt float [[DIV]], 0.000000e+00 +; CHECK-NEXT: ret i1 [[CMP]] +; + %div = fdiv ninf float 2.0, %X + %cmp = fcmp ogt float %div, 0.0 + ret i1 %cmp +} + +; Do not fold 1.0 / X > 0.0 when ninf is missing +define i1 @test25_recipX_noninf_div(float %X) { +; CHECK-LABEL: @test25_recipX_noninf_div( +; CHECK-NEXT: [[DIV:%.*]] = fdiv float 2.000000e+00, [[X:%.*]] +; CHECK-NEXT: [[CMP:%.*]] = fcmp ninf ogt float [[DIV]], 0.000000e+00 +; CHECK-NEXT: ret i1 [[CMP]] +; + %div = fdiv float 2.0, %X + %cmp = fcmp ninf ogt float %div, 0.0 + ret i1 %cmp +} + +; Do not fold 1.0 / X > 0.0 with unordered predicates +define i1 @test26_recipX_unorderd(float %X) { +; CHECK-LABEL: @test26_recipX_unorderd( +; CHECK-NEXT: [[DIV:%.*]] = fdiv ninf float 2.000000e+00, [[X:%.*]] +; CHECK-NEXT: [[CMP:%.*]] = fcmp ninf ugt float [[DIV]], 0.000000e+00 +; CHECK-NEXT: ret i1 [[CMP]] +; + %div = fdiv ninf float 2.0, %X + %cmp = fcmp ninf ugt float %div, 0.0 + ret i1 %cmp +} + +; Fold <-1.0, -1.0> / X > <-0.0, -0.0> +define <2 x i1> @test27_recipX_gt_vecsplat(<2 x float> %X) { +; CHECK-LABEL: @test27_recipX_gt_vecsplat( +; CHECK-NEXT: [[DIV:%.*]] = fdiv ninf <2 x float> , [[X:%.*]] +; CHECK-NEXT: [[CMP:%.*]] = fcmp ninf ogt <2 x float> [[DIV]], +; CHECK-NEXT: ret <2 x i1> [[CMP]] +; + %div = fdiv ninf <2 x float> , %X + %cmp = fcmp ninf ogt <2 x float> %div, + ret <2 x i1> %cmp +} +