diff options
| author | Chandler Carruth <chandlerc@gmail.com> | 2014-10-11 11:03:30 +0000 |
|---|---|---|
| committer | Chandler Carruth <chandlerc@gmail.com> | 2014-10-11 11:03:30 +0000 |
| commit | b29a74389190d649aeb96a5d1f949a3aaf4e744a (patch) | |
| tree | 7ea9510a8565841541f2d2ceb2f9198eba797244 /clang/test/CodeGen/complex-math.c | |
| parent | 8d57d2510fe71c37dda0d3219a3411ffad0cee3e (diff) | |
| download | bcm5719-llvm-b29a74389190d649aeb96a5d1f949a3aaf4e744a.tar.gz bcm5719-llvm-b29a74389190d649aeb96a5d1f949a3aaf4e744a.zip | |
[complex] Teach the other two binary operators on complex numbers (==
and !=) to support mixed complex and real operand types.
This requires removing an assert from SemaChecking, and adding support
both to the constant evaluator and the code generator to synthesize the
imaginary part when needed. This seemed somewhat cleaner than having
just the comparison operators force real-to-complex conversions.
I've added test cases for these operations. I'm really terrified that
there were *no* tests in-tree which exercised this.
This turned up when trying to build R after my change to the complex
type lowering.
llvm-svn: 219570
Diffstat (limited to 'clang/test/CodeGen/complex-math.c')
| -rw-r--r-- | clang/test/CodeGen/complex-math.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/clang/test/CodeGen/complex-math.c b/clang/test/CodeGen/complex-math.c index ca04e8d94d1..27540c78f77 100644 --- a/clang/test/CodeGen/complex-math.c +++ b/clang/test/CodeGen/complex-math.c @@ -367,3 +367,54 @@ long double _Complex div_long_double_cc(long double _Complex a, long double _Com // X86: ret return a / b; } + +// Comparison operators don't rely on library calls or have interseting math +// properties, but test that mixed types work correctly here. +_Bool eq_float_cr(float _Complex a, float b) { + // X86-LABEL: @eq_float_cr( + // X86: fcmp oeq + // X86: fcmp oeq + // X86: and i1 + // X86: ret + return a == b; +} +_Bool eq_float_rc(float a, float _Complex b) { + // X86-LABEL: @eq_float_rc( + // X86: fcmp oeq + // X86: fcmp oeq + // X86: and i1 + // X86: ret + return a == b; +} +_Bool eq_float_cc(float _Complex a, float _Complex b) { + // X86-LABEL: @eq_float_cc( + // X86: fcmp oeq + // X86: fcmp oeq + // X86: and i1 + // X86: ret + return a == b; +} +_Bool ne_float_cr(float _Complex a, float b) { + // X86-LABEL: @ne_float_cr( + // X86: fcmp une + // X86: fcmp une + // X86: or i1 + // X86: ret + return a != b; +} +_Bool ne_float_rc(float a, float _Complex b) { + // X86-LABEL: @ne_float_rc( + // X86: fcmp une + // X86: fcmp une + // X86: or i1 + // X86: ret + return a != b; +} +_Bool ne_float_cc(float _Complex a, float _Complex b) { + // X86-LABEL: @ne_float_cc( + // X86: fcmp une + // X86: fcmp une + // X86: or i1 + // X86: ret + return a != b; +} |

