diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2018-11-05 18:09:10 +0000 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2018-11-05 18:09:10 +0000 |
| commit | 1cfba9b5edae7ae3c2c6694fa438187964411bc5 (patch) | |
| tree | 6b40dea8ca937a2d729bb72ef1ee9e73a533186b /llvm/test/Transforms | |
| parent | 4911023fe3fd3a142d1077149fc3bcd9948dece8 (diff) | |
| download | bcm5719-llvm-1cfba9b5edae7ae3c2c6694fa438187964411bc5.tar.gz bcm5719-llvm-1cfba9b5edae7ae3c2c6694fa438187964411bc5.zip | |
[InstCombine] add/adjust tests for fcmp+select substitution; NFC
There was no coverage for at least 2 out of the 4 patterns because
of fcmp canonicalization. The tests and code should be moved to
InstSimplify in a follow-up because this doesn't create any new values.
llvm-svn: 346150
Diffstat (limited to 'llvm/test/Transforms')
| -rw-r--r-- | llvm/test/Transforms/InstCombine/fcmp-select.ll | 119 |
1 files changed, 91 insertions, 28 deletions
diff --git a/llvm/test/Transforms/InstCombine/fcmp-select.ll b/llvm/test/Transforms/InstCombine/fcmp-select.ll index e04ab3e8923..7fc59bbcb7d 100644 --- a/llvm/test/Transforms/InstCombine/fcmp-select.ll +++ b/llvm/test/Transforms/InstCombine/fcmp-select.ll @@ -1,53 +1,116 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt < %s -instcombine -S | FileCheck %s +declare void @use(i1) + +; X == 42.0 ? X : 42.0 --> 42.0 + +define double @oeq(double %x) { +; CHECK-LABEL: @oeq( +; CHECK-NEXT: [[CMP:%.*]] = fcmp oeq double [[X:%.*]], 4.200000e+01 +; CHECK-NEXT: call void @use(i1 [[CMP]]) +; CHECK-NEXT: ret double 4.200000e+01 +; + %cmp = fcmp oeq double %x, 42.0 + call void @use(i1 %cmp) ; extra use to thwart predicate canonicalization + %cond = select i1 %cmp, double %x, double 42.0 + ret double %cond +} + +; X == 42.0 ? 42.0 : X --> X + +define float @oeq_swapped(float %x) { +; CHECK-LABEL: @oeq_swapped( +; CHECK-NEXT: [[CMP:%.*]] = fcmp oeq float [[X:%.*]], 4.200000e+01 +; CHECK-NEXT: call void @use(i1 [[CMP]]) +; CHECK-NEXT: ret float [[X]] +; + %cmp = fcmp oeq float %x, 42.0 + call void @use(i1 %cmp) ; extra use to thwart predicate canonicalization + %cond = select i1 %cmp, float 42.0, float %x + ret float %cond +} + ; x != y ? x : y -> x if it's the right kind of != and at least ; one of x and y is not negative zero. -; CHECK: f0 -; CHECK: ret double %x -define double @f0(double %x) nounwind readnone { -entry: - %cmp = fcmp une double %x, -1.0 - %cond = select i1 %cmp, double %x, double -1.0 +; X != 42.0 ? X : 42.0 --> X + +define double @une(double %x) { +; CHECK-LABEL: @une( +; CHECK-NEXT: [[CMP:%.*]] = fcmp une double [[X:%.*]], 4.200000e+01 +; CHECK-NEXT: call void @use(i1 [[CMP]]) +; CHECK-NEXT: ret double [[X]] +; + %cmp = fcmp une double %x, 42.0 + call void @use(i1 %cmp) ; extra use to thwart predicate canonicalization + %cond = select i1 %cmp, double %x, double 42.0 ret double %cond } -; CHECK: f1 -; CHECK: ret double -1.000000e+00 -define double @f1(double %x) nounwind readnone { -entry: - %cmp = fcmp une double %x, -1.0 - %cond = select i1 %cmp, double -1.0, double %x + +; X != 42.0 ? 42.0 : X --> 42.0 + +define double @une_swapped(double %x) { +; CHECK-LABEL: @une_swapped( +; CHECK-NEXT: [[CMP:%.*]] = fcmp une double [[X:%.*]], 4.200000e+01 +; CHECK-NEXT: call void @use(i1 [[CMP]]) +; CHECK-NEXT: ret double 4.200000e+01 +; + %cmp = fcmp une double %x, 42.0 + call void @use(i1 %cmp) ; extra use to thwart predicate canonicalization + %cond = select i1 %cmp, double 42.0, double %x ret double %cond } -; CHECK: f2 -; CHECK: ret double %cond -define double @f2(double %x, double %y) nounwind readnone { -entry: + +define double @une_could_be_negzero(double %x, double %y) { +; CHECK-LABEL: @une_could_be_negzero( +; CHECK-NEXT: [[CMP:%.*]] = fcmp une double [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: call void @use(i1 [[CMP]]) +; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], double [[X]], double [[Y]] +; CHECK-NEXT: ret double [[COND]] +; %cmp = fcmp une double %x, %y + call void @use(i1 %cmp) ; extra use to thwart predicate canonicalization %cond = select i1 %cmp, double %x, double %y ret double %cond } -; CHECK: f3 -; CHECK: ret double %cond -define double @f3(double %x, double %y) nounwind readnone { -entry: + +define double @une_swapped_could_be_negzero(double %x, double %y) { +; CHECK-LABEL: @une_swapped_could_be_negzero( +; CHECK-NEXT: [[CMP:%.*]] = fcmp une double [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: call void @use(i1 [[CMP]]) +; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], double [[Y]], double [[X]] +; CHECK-NEXT: ret double [[COND]] +; %cmp = fcmp une double %x, %y + call void @use(i1 %cmp) ; extra use to thwart predicate canonicalization %cond = select i1 %cmp, double %y, double %x ret double %cond } -; CHECK: f4 -; CHECK: ret double %cond -define double @f4(double %x) nounwind readnone { -entry: + +define double @one(double %x) { +; CHECK-LABEL: @one( +; CHECK-NEXT: [[CMP:%.*]] = fcmp one double [[X:%.*]], -1.000000e+00 +; CHECK-NEXT: call void @use(i1 [[CMP]]) +; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], double [[X]], double -1.000000e+00 +; CHECK-NEXT: ret double [[COND]] +; %cmp = fcmp one double %x, -1.0 + call void @use(i1 %cmp) ; extra use to thwart predicate canonicalization %cond = select i1 %cmp, double %x, double -1.0 ret double %cond } -; CHECK: f5 -; CHECK: ret double %cond -define double @f5(double %x) nounwind readnone { -entry: + +define double @one_swapped(double %x) { +; CHECK-LABEL: @one_swapped( +; CHECK-NEXT: [[CMP:%.*]] = fcmp one double [[X:%.*]], -1.000000e+00 +; CHECK-NEXT: call void @use(i1 [[CMP]]) +; CHECK-NEXT: [[COND:%.*]] = select i1 [[CMP]], double -1.000000e+00, double [[X]] +; CHECK-NEXT: ret double [[COND]] +; %cmp = fcmp one double %x, -1.0 + call void @use(i1 %cmp) ; extra use to thwart predicate canonicalization %cond = select i1 %cmp, double -1.0, double %x ret double %cond } + |

