File tree Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Expand file tree Collapse file tree 2 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -289,12 +289,10 @@ static bool runIPSCCP(
289
289
if (ReturnValue.isConstantRangeIncludingUndef ())
290
290
continue ;
291
291
292
- // Do not touch existing attribute for now.
293
- // TODO: We should be able to take the intersection of the existing
294
- // attribute and the inferred range.
292
+ // Take the intersection of the existing attribute and the inferred range.
293
+ ConstantRange CR = ReturnValue.getConstantRange ();
295
294
if (F->hasRetAttribute (Attribute::Range))
296
- continue ;
297
- auto &CR = ReturnValue.getConstantRange ();
295
+ CR = CR.intersectWith (F->getRetAttribute (Attribute::Range).getRange ());
298
296
F->addRangeRetAttr (CR);
299
297
continue ;
300
298
}
Original file line number Diff line number Diff line change
1
+ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2
+ ; RUN: opt < %s -passes=ipsccp -S | FileCheck %s
3
+
4
+ declare range(i32 0 , 20 ) i32 @callee (i32 )
5
+
6
+ define range(i32 10 , 30 ) i32 @caller (i32 %x ) {
7
+ ; CHECK-LABEL: define range(i32 10, 20) i32 @caller(
8
+ ; CHECK-SAME: i32 [[X:%.*]]) {
9
+ ; CHECK-NEXT: [[ENTRY:.*:]]
10
+ ; CHECK-NEXT: [[CALL:%.*]] = call range(i32 0, 20) i32 @callee()
11
+ ; CHECK-NEXT: ret i32 [[CALL]]
12
+ ;
13
+ entry:
14
+ %call = call range(i32 0 , 20 ) i32 @callee ()
15
+ ret i32 %call
16
+ }
You can’t perform that action at this time.
0 commit comments