[cfe-commits] r39841 - in /cfe/trunk: CodeGen/CGExpr.cpp test/CodeGen/complex.c

Chris Lattner clattner at apple.com
Fri Jul 13 17:11:24 PDT 2007


> @@ -1231,9 +1247,23 @@
>      }
>    } else {
>      // Struct/union/complex
> -    assert(0 && "Aggregate comparisons not implemented yet!");
> +    llvm::Value *LHSR, *LHSI, *RHSR, *RHSI, *ResultR, *ResultI;
> +    EmitLoadOfComplex(LHS, LHSR, LHSI);
> +    EmitLoadOfComplex(RHS, RHSR, RHSI);
> +
> +    ResultR = Builder.CreateFCmp((llvm::FCmpInst::Predicate)FCmpOpc,
> +				 LHSR, RHSR, "cmp.r");
> +    ResultI = Builder.CreateFCmp((llvm::FCmpInst::Predicate)FCmpOpc,
> +				 LHSI, RHSI, "cmp.i");
> +    if (BinaryOperator::EQ == E->getOpcode()) {
> +      Result = Builder.CreateAnd(ResultR, ResultI, "and.ri");
> +    } else if (BinaryOperator::NE == E->getOpcode()) {
> +      Result = Builder.CreateOr(ResultR, ResultI, "or.ri");
> +    } else {
> +      assert(0 && "Complex comparison other than == or != ?");
> +    }

Please add a FIXME for integer complex comparisons, thanks Gabor!

-Chris







More information about the cfe-commits mailing list