Skip to content

ashr, lshr, shl, udiv should have an 'isexact' bit indicating it is known to only shift out zeros #9234

@lattner

Description

@lattner
Bugzilla Link 8862
Resolution FIXED
Resolved on Feb 09, 2011 23:39
Version trunk
OS All
Blocks llvm/llvm-bugzilla-archive#8882 llvm/llvm-bugzilla-archive#8942
CC @lattner,@sunfishcode

Extended Description

Instcombine should compile this identity function to return X:

define i32 @​test(i32 %X) {
%A = sdiv exact i32 %X, 4
%B = mul i32 %A, 4
ret i32 %B
}

instead we get:

define i32 @​test(i32 %X) {
%A1 = and i32 %X, -4
ret i32 %A1
}

This is because it simplifies the sdiv into an ashr instruction, which loses information. This sort of thing comes up when handling array/pointer difference stuff.

To fix this, SDISel whould lower sdiv exact into ashr, instcombine should handle sdiv's as aggressively as ashr's, and then we should stop canonicalizing ashr to sdiv in instcombine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions