mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-23 01:25:32 +00:00
Multiply was very wrong for wrapped ranges. This supplies a half-fix that will
generally return Full on all wrapped inputs. "Fixes" PR4545. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75444 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -557,13 +557,13 @@ ConstantRange::multiply(const ConstantRange &Other) const {
|
||||
if (isFullSet() || Other.isFullSet())
|
||||
return ConstantRange(getBitWidth(), /*isFullSet=*/true);
|
||||
|
||||
ConstantRange this_zext = zeroExtend(getBitWidth() * 2);
|
||||
ConstantRange Other_zext = Other.zeroExtend(getBitWidth() * 2);
|
||||
|
||||
ConstantRange Result_zext = ConstantRange(
|
||||
this_zext.getLower() * Other_zext.getLower(),
|
||||
((this_zext.getUpper()-1) * (Other_zext.getUpper()-1)) + 1);
|
||||
APInt this_min = getUnsignedMin().zext(getBitWidth() * 2);
|
||||
APInt this_max = getUnsignedMax().zext(getBitWidth() * 2);
|
||||
APInt Other_min = Other.getUnsignedMin().zext(getBitWidth() * 2);
|
||||
APInt Other_max = Other.getUnsignedMax().zext(getBitWidth() * 2);
|
||||
|
||||
ConstantRange Result_zext = ConstantRange(this_min * Other_min,
|
||||
this_max * Other_max + 1);
|
||||
return Result_zext.truncate(getBitWidth());
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user