Change EmitUsualArithmeticConversions to use EmitExprWithUsualUnaryConversions.

This allows us to compile:

  register short X;
  {
    int Y;
    return 1+X+Y;

into:

        %tmp = load i16* %X             ; <i16> [#uses=1]
        %promote = sext i16 %tmp to i32         ; <i32> [#uses=1]
        %tmp1 = add i32 1, %promote             ; <i32> [#uses=1]
        %tmp2 = load i32* %Y            ; <i32> [#uses=1]
        %tmp3 = add i32 %tmp1, %tmp2            ; <i32> [#uses=1]
        ret i32 %tmp3

Look at the amazing sign extension, so much happier than an assertion failure. :)

llvm-svn: 39565
This commit is contained in:
Chris Lattner 2007-06-02 22:51:30 +00:00
parent 6db1fb845a
commit c18f9d1aed
1 changed files with 4 additions and 3 deletions

View File

@ -246,9 +246,10 @@ ExprResult CodeGenFunction::EmitUnaryLNot(const UnaryOperator *E) {
void CodeGenFunction::EmitUsualArithmeticConversions(const BinaryOperator *E,
ExprResult &LHS,
ExprResult &RHS) {
// FIXME: implement right.
LHS = EmitExpr(E->getLHS());
RHS = EmitExpr(E->getRHS());
QualType LHSType, RHSType;
LHS = EmitExprWithUsualUnaryConversions(E->getLHS(), LHSType);
RHS = EmitExprWithUsualUnaryConversions(E->getRHS(), RHSType);
}