[llvm-commits] [llvm-gcc-4.0] r42399 - /llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp

Chris Lattner sabre at nondot.org
Thu Sep 27 08:47:42 PDT 2007


Author: lattner
Date: Thu Sep 27 10:47:41 2007
New Revision: 42399

URL: http://llvm.org/viewvc/llvm-project?rev=42399&view=rev
Log:
Fix PR1708 and test/CFrontend/2007-09-27-ComplexIntCompare.c


Modified:
    llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp

Modified: llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp?rev=42399&r1=42398&r2=42399&view=diff

==============================================================================
--- llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp Thu Sep 27 10:47:41 2007
@@ -5141,14 +5141,22 @@
     break;
   }
   case EQ_EXPR:   // (a+ib) == (c+id) = (a == c) & (b == d)
-    // FIXME: What about integer complex?
-    DSTr = Builder.CreateFCmpOEQ(LHSr, RHSr, "tmpr");
-    DSTi = Builder.CreateFCmpOEQ(LHSi, RHSi, "tmpi");
+    if (LHSr->getType()->isFloatingPoint()) {
+      DSTr = Builder.CreateFCmpOEQ(LHSr, RHSr, "tmpr");
+      DSTi = Builder.CreateFCmpOEQ(LHSi, RHSi, "tmpi");
+    } else {
+      DSTr = Builder.CreateICmpEQ(LHSr, RHSr, "tmpr");
+      DSTi = Builder.CreateICmpEQ(LHSi, RHSi, "tmpi");
+    }
     return Builder.CreateAnd(DSTr, DSTi, "tmp");
   case NE_EXPR:   // (a+ib) != (c+id) = (a != c) | (b != d) 
-    // FIXME: What about integer complex?
-    DSTr = Builder.CreateFCmpUNE(LHSr, RHSr, "tmpr");
-    DSTi = Builder.CreateFCmpUNE(LHSi, RHSi, "tmpi");
+    if (LHSr->getType()->isFloatingPoint()) {
+      DSTr = Builder.CreateFCmpUNE(LHSr, RHSr, "tmpr");
+      DSTi = Builder.CreateFCmpUNE(LHSi, RHSi, "tmpi");
+    } else {
+      DSTr = Builder.CreateICmpEQ(LHSr, RHSr, "tmpr");
+      DSTi = Builder.CreateICmpEQ(LHSi, RHSi, "tmpi");
+    }
     return Builder.CreateOr(DSTr, DSTi, "tmp");
   }
   





More information about the llvm-commits mailing list