File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
test/Transforms/CorrelatedValuePropagation Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -376,9 +376,17 @@ FPClassTest CallBase::getParamNoFPClass(unsigned i) const {
376376}
377377
378378std::optional<ConstantRange> CallBase::getRange () const {
379- const Attribute RangeAttr = getRetAttr (llvm::Attribute::Range);
380- if (RangeAttr.isValid ())
381- return RangeAttr.getRange ();
379+ Attribute CallAttr = Attrs.getRetAttr (Attribute::Range);
380+ Attribute FnAttr;
381+ if (const Function *F = getCalledFunction ())
382+ FnAttr = F->getRetAttribute (Attribute::Range);
383+
384+ if (CallAttr.isValid () && FnAttr.isValid ())
385+ return CallAttr.getRange ().intersectWith (FnAttr.getRange ());
386+ if (CallAttr.isValid ())
387+ return CallAttr.getRange ();
388+ if (FnAttr.isValid ())
389+ return FnAttr.getRange ();
382390 return std::nullopt ;
383391}
384392
Original file line number Diff line number Diff line change @@ -312,11 +312,9 @@ define i8 @ucmp_switch_callsite_range(i32 %x, i32 %y) {
312312; CHECK-LABEL: @ucmp_switch_callsite_range(
313313; CHECK-NEXT: [[CMP:%.*]] = call range(i8 -2, 3) i8 @llvm.ucmp.i8.i32(i32 [[X:%.*]], i32 [[Y:%.*]])
314314; CHECK-NEXT: switch i8 [[CMP]], label [[DEFAULT_UNREACHABLE:%.*]] [
315- ; CHECK-NEXT: i8 -2 , label [[BB_NEG2 :%.*]]
315+ ; CHECK-NEXT: i8 1 , label [[BB_1 :%.*]]
316316; CHECK-NEXT: i8 -1, label [[BB_NEG1:%.*]]
317317; CHECK-NEXT: i8 0, label [[BB_0:%.*]]
318- ; CHECK-NEXT: i8 1, label [[BB_1:%.*]]
319- ; CHECK-NEXT: i8 2, label [[BB_2:%.*]]
320318; CHECK-NEXT: ]
321319; CHECK: bb.neg2:
322320; CHECK-NEXT: ret i8 -2
You can’t perform that action at this time.
0 commit comments