[cfe-commits] r39565 - /cfe/cfe/trunk/CodeGen/CGExpr.cpp

clattner at cs.uiuc.edu clattner at cs.uiuc.edu
Wed Jul 11 09:45:40 PDT 2007


Author: clattner
Date: Wed Jul 11 11:45:40 2007
New Revision: 39565

URL: http://llvm.org/viewvc/llvm-project?rev=39565&view=rev
Log:
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. :)

Modified:
    cfe/cfe/trunk/CodeGen/CGExpr.cpp

Modified: cfe/cfe/trunk/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/CodeGen/CGExpr.cpp?rev=39565&r1=39564&r2=39565&view=diff

==============================================================================
--- cfe/cfe/trunk/CodeGen/CGExpr.cpp (original)
+++ cfe/cfe/trunk/CodeGen/CGExpr.cpp Wed Jul 11 11:45:40 2007
@@ -246,9 +246,10 @@
 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);
+
 }
 
 





More information about the cfe-commits mailing list