diff options
author | Sanjay Patel <spatel@rotateright.com> | 2018-01-08 18:31:13 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2018-01-08 18:31:13 +0000 |
commit | 7dfe96ad16734766bc061224a56b576fdea0af17 (patch) | |
tree | 0e99acfb51d1aaa6a5bb8ae0afbaa90480e48461 | |
parent | e9500ba745b76adf0c35d31b3d4fb21af151383c (diff) | |
download | bcm5719-llvm-7dfe96ad16734766bc061224a56b576fdea0af17.tar.gz bcm5719-llvm-7dfe96ad16734766bc061224a56b576fdea0af17.zip |
[ValueTracking] remove overzealous assert
The test is derived from a failing fuzz test:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=5008
Credit to @rksimon for pointing out the problem.
llvm-svn: 322016
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 2 | ||||
-rw-r--r-- | llvm/test/Transforms/InstCombine/minmax-fold.ll | 21 |
2 files changed, 22 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index a0032f99ec2..b8f6066bf05 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -4214,7 +4214,7 @@ static SelectPatternResult matchMinMaxOfMinMax(CmpInst::Predicate Pred, break; return {SPF_UNKNOWN, SPNB_NA, false}; default: - llvm_unreachable("Bad flavor while matching min/max"); + return {SPF_UNKNOWN, SPNB_NA, false}; } // a pred c ? m(a, b) : m(c, b) --> m(m(a, b), m(c, b)) diff --git a/llvm/test/Transforms/InstCombine/minmax-fold.ll b/llvm/test/Transforms/InstCombine/minmax-fold.ll index 7c1fe1127d1..373d312585e 100644 --- a/llvm/test/Transforms/InstCombine/minmax-fold.ll +++ b/llvm/test/Transforms/InstCombine/minmax-fold.ll @@ -887,3 +887,24 @@ define i32 @common_factor_umax_extra_use_both(i32 %a, i32 %b, i32 %c) { ret i32 %max_abc } +; This would assert. Don't assume that earlier min/max types match a possible later min/max. + +define float @not_min_of_min(i8 %i, float %x) { +; CHECK-LABEL: @not_min_of_min( +; CHECK-NEXT: [[CMP1_INV:%.*]] = fcmp fast oge float [[X:%.*]], 1.000000e+00 +; CHECK-NEXT: [[MIN1:%.*]] = select i1 [[CMP1_INV]], float 1.000000e+00, float [[X]] +; CHECK-NEXT: [[CMP2_INV:%.*]] = fcmp fast oge float [[X]], 2.000000e+00 +; CHECK-NEXT: [[MIN2:%.*]] = select i1 [[CMP2_INV]], float 2.000000e+00, float [[X]] +; CHECK-NEXT: [[CMP3:%.*]] = icmp ult i8 [[I:%.*]], 16 +; CHECK-NEXT: [[R:%.*]] = select i1 [[CMP3]], float [[MIN1]], float [[MIN2]] +; CHECK-NEXT: ret float [[R]] +; + %cmp1 = fcmp fast ult float %x, 1.0 + %min1 = select i1 %cmp1, float %x, float 1.0 + %cmp2 = fcmp fast ult float %x, 2.0 + %min2 = select i1 %cmp2, float %x, float 2.0 + %cmp3 = icmp ult i8 %i, 16 + %r = select i1 %cmp3, float %min1, float %min2 + ret float %r +} + |