- Teach SPU64InstrInfo.td about the remaining signed comparisons, update tests
  accordingly.

llvm-svn: 61672
This commit is contained in:
Scott Michel 2009-01-05 04:05:53 +00:00
parent 8a7d10d753
commit 74f249517e
3 changed files with 418 additions and 173 deletions

View File

@ -86,7 +86,7 @@ def : I64SETCCNegCond<setne, I64EQr64>;
def : I64SELECTNegCond<setne, I64EQr64>; def : I64SELECTNegCond<setne, I64EQr64>;
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
// i64 setugt: // i64 setugt/setule:
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
def CLGTr64ugt: def CLGTr64ugt:
@ -130,3 +130,113 @@ def : Pat<(setugt (v2i64 VECREG:$rA), (v2i64 VECREG:$rB)),
// i64 setult: // i64 setult:
def : I64SETCCNegCond<setule, I64LGTr64>; def : I64SETCCNegCond<setule, I64LGTr64>;
def : I64SELECTNegCond<setule, I64LGTr64>; def : I64SELECTNegCond<setule, I64LGTr64>;
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
// i64 setuge/setult:
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
def CLGEr64compare:
CodeFrag<(CGTIv4i32 (GBv4i32 (ORv4i32 CLGTr64ugt.Fragment,
CLGTr64eq.Fragment)), 0xb)>;
def CLGEv2i64compare:
CodeFrag<(CEQIv4i32 (GBv4i32 (ORv4i32 CLGTv2i64ugt.Fragment,
CLGTv2i64eq.Fragment)), 0xf)>;
multiclass CompareLogicalGreaterEqual64 {
// Plain old comparison, converts back to i32 scalar
def r64: CodeFrag<(ORi32_v4i32 CLGEr64compare.Fragment)>;
def v2i64: CodeFrag<CLGEv2i64compare.Fragment>;
// SELB mask from FSM:
def r64mask: CodeFrag<(ORi32_v4i32 (FSMv4i32 CLGEr64compare.Fragment))>;
def v2i64mask: CodeFrag<(ORi32_v4i32 (FSMv4i32 CLGEv2i64compare.Fragment))>;
}
defm I64LGE: CompareLogicalGreaterEqual64;
def : Pat<(setuge R64C:$rA, R64C:$rB), I64LGEr64.Fragment>;
def : Pat<(setuge (v2i64 VECREG:$rA), (v2i64 VECREG:$rB)),
I64LGEv2i64.Fragment>;
// i64 setult:
def : I64SETCCNegCond<setult, I64LGEr64>;
def : I64SELECTNegCond<setult, I64LGEr64>;
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
// i64 setgt/setle:
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
def CGTr64sgt:
CodeFrag<(CGTv4i32 (ORv2i64_i64 R64C:$rA), (ORv2i64_i64 R64C:$rB))>;
def CGTr64eq:
CodeFrag<(CEQv4i32 (ORv2i64_i64 R64C:$rA), (ORv2i64_i64 R64C:$rB))>;
def CGTr64compare:
CodeFrag<(SELBv2i64 CGTr64sgt.Fragment,
(XSWDv2i64 CGTr64sgt.Fragment),
CGTr64eq.Fragment)>;
def CGTv2i64sgt:
CodeFrag<(CGTv4i32 VECREG:$rA, VECREG:$rB)>;
def CGTv2i64eq:
CodeFrag<(CEQv4i32 VECREG:$rA, VECREG:$rB)>;
def CGTv2i64compare:
CodeFrag<(SELBv2i64 CGTv2i64sgt.Fragment,
(XSWDv2i64 CGTr64sgt.Fragment),
CGTv2i64eq.Fragment)>;
multiclass CompareGreaterThan64 {
// Plain old comparison, converts back to i32 scalar
def r64: CodeFrag<(ORi32_v4i32 CGTr64compare.Fragment)>;
def v2i64: CodeFrag<CGTv2i64compare.Fragment>;
// SELB mask from FSM:
def r64mask: CodeFrag<(ORi32_v4i32 (FSMv4i32 CGTr64compare.Fragment))>;
def v2i64mask: CodeFrag<(ORi32_v4i32 (FSMv4i32 CGTv2i64compare.Fragment))>;
}
defm I64GT: CompareLogicalGreaterThan64;
def : Pat<(setgt R64C:$rA, R64C:$rB), I64GTr64.Fragment>;
def : Pat<(setgt (v2i64 VECREG:$rA), (v2i64 VECREG:$rB)),
I64GTv2i64.Fragment>;
// i64 setult:
def : I64SETCCNegCond<setle, I64GTr64>;
def : I64SELECTNegCond<setle, I64GTr64>;
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
// i64 setge/setlt:
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
def CGEr64compare:
CodeFrag<(CGTIv4i32 (GBv4i32 (ORv4i32 CGTr64sgt.Fragment,
CGTr64eq.Fragment)), 0xb)>;
def CGEv2i64compare:
CodeFrag<(CEQIv4i32 (GBv4i32 (ORv4i32 CGTv2i64sgt.Fragment,
CGTv2i64eq.Fragment)), 0xf)>;
multiclass CompareGreaterEqual64 {
// Plain old comparison, converts back to i32 scalar
def r64: CodeFrag<(ORi32_v4i32 CGEr64compare.Fragment)>;
def v2i64: CodeFrag<CGEv2i64compare.Fragment>;
// SELB mask from FSM:
def r64mask: CodeFrag<(ORi32_v4i32 (FSMv4i32 CGEr64compare.Fragment))>;
def v2i64mask: CodeFrag<(ORi32_v4i32 (FSMv4i32 CGEv2i64compare.Fragment))>;
}
defm I64GE: CompareGreaterEqual64;
def : Pat<(setge R64C:$rA, R64C:$rB), I64GEr64.Fragment>;
def : Pat<(setge (v2i64 VECREG:$rA), (v2i64 VECREG:$rB)),
I64GEv2i64.Fragment>;
// i64 setult:
def : I64SETCCNegCond<setlt, I64GEr64>;
def : I64SELECTNegCond<setlt, I64GEr64>;

View File

@ -1,11 +1,12 @@
; RUN: llvm-as -o - %s | llc -march=cellspu > %t1.s ; RUN: llvm-as -o - %s | llc -march=cellspu > %t1.s
; RUN: grep ceq %t1.s | count 6 ; RUN: grep ceq %t1.s | count 20
; RUN: grep cgti %t1.s | count 4 ; RUN: grep cgti %t1.s | count 12
; RUN: grep clgt %t1.s | count 2 ; RUN: grep cgt %t1.s | count 16
; RUN: grep gb %t1.s | count 4 ; RUN: grep clgt %t1.s | count 12
; RUN: grep fsm %t1.s | count 3 ; RUN: grep gb %t1.s | count 12
; RUN: grep xori %t1.s | count 1 ; RUN: grep fsm %t1.s | count 10
; RUN: grep selb %t1.s | count 5 ; RUN: grep xori %t1.s | count 5
; RUN: grep selb %t1.s | count 18
target datalayout = "E-p:32:32:128-f64:64:128-f32:32:128-i64:32:128-i32:32:128-i16:16:128-i8:8:128-i1:8:128-a0:0:128-v128:128:128-s0:128:128" target datalayout = "E-p:32:32:128-f64:64:128-f32:32:128-i64:32:128-i32:32:128-i16:16:128-i8:8:128-i1:8:128-a0:0:128-v128:128:128-s0:128:128"
target triple = "spu" target triple = "spu"
@ -53,93 +54,93 @@ entry:
ret i1 %A ret i1 %A
} }
;; define i64 @icmp_uge_select_i64(i64 %arg1, i64 %arg2, i64 %val1, i64 %val2) nounwind { define i64 @icmp_uge_select_i64(i64 %arg1, i64 %arg2, i64 %val1, i64 %val2) nounwind {
;; entry: entry:
;; %A = icmp uge i64 %arg1, %arg2 %A = icmp uge i64 %arg1, %arg2
;; %B = select i1 %A, i64 %val1, i64 %val2 %B = select i1 %A, i64 %val1, i64 %val2
;; ret i64 %B ret i64 %B
;; } }
;;
;; define i1 @icmp_uge_setcc_i64(i64 %arg1, i64 %arg2, i64 %val1, i64 %val2) nounwind { define i1 @icmp_uge_setcc_i64(i64 %arg1, i64 %arg2, i64 %val1, i64 %val2) nounwind {
;; entry: entry:
;; %A = icmp uge i64 %arg1, %arg2 %A = icmp uge i64 %arg1, %arg2
;; ret i1 %A ret i1 %A
;; } }
;;
;; define i64 @icmp_ult_select_i64(i64 %arg1, i64 %arg2, i64 %val1, i64 %val2) nounwind { define i64 @icmp_ult_select_i64(i64 %arg1, i64 %arg2, i64 %val1, i64 %val2) nounwind {
;; entry: entry:
;; %A = icmp ult i64 %arg1, %arg2 %A = icmp ult i64 %arg1, %arg2
;; %B = select i1 %A, i64 %val1, i64 %val2 %B = select i1 %A, i64 %val1, i64 %val2
;; ret i64 %B ret i64 %B
;; } }
;;
;; define i1 @icmp_ult_setcc_i64(i64 %arg1, i64 %arg2, i64 %val1, i64 %val2) nounwind { define i1 @icmp_ult_setcc_i64(i64 %arg1, i64 %arg2, i64 %val1, i64 %val2) nounwind {
;; entry: entry:
;; %A = icmp ult i64 %arg1, %arg2 %A = icmp ult i64 %arg1, %arg2
;; ret i1 %A ret i1 %A
;; } }
;;
;; define i64 @icmp_ule_select_i64(i64 %arg1, i64 %arg2, i64 %val1, i64 %val2) nounwind { define i64 @icmp_ule_select_i64(i64 %arg1, i64 %arg2, i64 %val1, i64 %val2) nounwind {
;; entry: entry:
;; %A = icmp ule i64 %arg1, %arg2 %A = icmp ule i64 %arg1, %arg2
;; %B = select i1 %A, i64 %val1, i64 %val2 %B = select i1 %A, i64 %val1, i64 %val2
;; ret i64 %B ret i64 %B
;; } }
;;
;; define i1 @icmp_ule_setcc_i64(i64 %arg1, i64 %arg2, i64 %val1, i64 %val2) nounwind { define i1 @icmp_ule_setcc_i64(i64 %arg1, i64 %arg2, i64 %val1, i64 %val2) nounwind {
;; entry: entry:
;; %A = icmp ule i64 %arg1, %arg2 %A = icmp ule i64 %arg1, %arg2
;; ret i1 %A ret i1 %A
;; } }
;;
;; define i64 @icmp_sgt_select_i64(i64 %arg1, i64 %arg2, i64 %val1, i64 %val2) nounwind { define i64 @icmp_sgt_select_i64(i64 %arg1, i64 %arg2, i64 %val1, i64 %val2) nounwind {
;; entry: entry:
;; %A = icmp sgt i64 %arg1, %arg2 %A = icmp sgt i64 %arg1, %arg2
;; %B = select i1 %A, i64 %val1, i64 %val2 %B = select i1 %A, i64 %val1, i64 %val2
;; ret i64 %B ret i64 %B
;; } }
;;
;; define i1 @icmp_sgt_setcc_i64(i64 %arg1, i64 %arg2, i64 %val1, i64 %val2) nounwind { define i1 @icmp_sgt_setcc_i64(i64 %arg1, i64 %arg2, i64 %val1, i64 %val2) nounwind {
;; entry: entry:
;; %A = icmp sgt i64 %arg1, %arg2 %A = icmp sgt i64 %arg1, %arg2
;; ret i1 %A ret i1 %A
;; } }
;;
;; define i64 @icmp_sge_select_i64(i64 %arg1, i64 %arg2, i64 %val1, i64 %val2) nounwind { define i64 @icmp_sge_select_i64(i64 %arg1, i64 %arg2, i64 %val1, i64 %val2) nounwind {
;; entry: entry:
;; %A = icmp sge i64 %arg1, %arg2 %A = icmp sge i64 %arg1, %arg2
;; %B = select i1 %A, i64 %val1, i64 %val2 %B = select i1 %A, i64 %val1, i64 %val2
;; ret i64 %B ret i64 %B
;; } }
;;
;; define i1 @icmp_sge_setcc_i64(i64 %arg1, i64 %arg2, i64 %val1, i64 %val2) nounwind { define i1 @icmp_sge_setcc_i64(i64 %arg1, i64 %arg2, i64 %val1, i64 %val2) nounwind {
;; entry: entry:
;; %A = icmp sge i64 %arg1, %arg2 %A = icmp sge i64 %arg1, %arg2
;; ret i1 %A ret i1 %A
;; } }
;;
;; define i64 @icmp_slt_select_i64(i64 %arg1, i64 %arg2, i64 %val1, i64 %val2) nounwind { define i64 @icmp_slt_select_i64(i64 %arg1, i64 %arg2, i64 %val1, i64 %val2) nounwind {
;; entry: entry:
;; %A = icmp slt i64 %arg1, %arg2 %A = icmp slt i64 %arg1, %arg2
;; %B = select i1 %A, i64 %val1, i64 %val2 %B = select i1 %A, i64 %val1, i64 %val2
;; ret i64 %B ret i64 %B
;; } }
;;
;; define i1 @icmp_slt_setcc_i64(i64 %arg1, i64 %arg2, i64 %val1, i64 %val2) nounwind { define i1 @icmp_slt_setcc_i64(i64 %arg1, i64 %arg2, i64 %val1, i64 %val2) nounwind {
;; entry: entry:
;; %A = icmp slt i64 %arg1, %arg2 %A = icmp slt i64 %arg1, %arg2
;; ret i1 %A ret i1 %A
;; } }
;;
;; define i64 @icmp_sle_select_i64(i64 %arg1, i64 %arg2, i64 %val1, i64 %val2) nounwind { define i64 @icmp_sle_select_i64(i64 %arg1, i64 %arg2, i64 %val1, i64 %val2) nounwind {
;; entry: entry:
;; %A = icmp sle i64 %arg1, %arg2 %A = icmp sle i64 %arg1, %arg2
;; %B = select i1 %A, i64 %val1, i64 %val2 %B = select i1 %A, i64 %val1, i64 %val2
;; ret i64 %B ret i64 %B
;; } }
;;
;; define i1 @icmp_sle_setcc_i64(i64 %arg1, i64 %arg2, i64 %val1, i64 %val2) nounwind { define i1 @icmp_sle_setcc_i64(i64 %arg1, i64 %arg2, i64 %val1, i64 %val2) nounwind {
;; entry: entry:
;; %A = icmp sle i64 %arg1, %arg2 %A = icmp sle i64 %arg1, %arg2
;; ret i1 %A ret i1 %A
;; } }

View File

@ -9,12 +9,12 @@ typedef long long int int64_t;
/* ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- */ /* ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- */
int64_t a = 1234567890003LL; int64_t tval_a = 1234567890003LL;
int64_t b = 2345678901235LL; int64_t tval_b = 2345678901235LL;
int64_t c = 1234567890001LL; int64_t tval_c = 1234567890001LL;
int64_t d = 10001LL; int64_t tval_d = 10001LL;
int64_t e = 10000LL; int64_t tval_e = 10000LL;
int64_t f = -1068103409991LL; int64_t tval_f = -1068103409991LL;
/* ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- */ /* ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- */
@ -30,6 +30,40 @@ i64_neq(int64_t a, int64_t b)
return (a != b); return (a != b);
} }
int
i64_gt(int64_t a, int64_t b)
{
return (a > b);
}
int
i64_le(int64_t a, int64_t b)
{
return (a <= b);
}
int
i64_ge(int64_t a, int64_t b) {
return (a >= b);
}
int
i64_lt(int64_t a, int64_t b) {
return (a < b);
}
int
i64_uge(uint64_t a, uint64_t b)
{
return (a >= b);
}
int
i64_ult(uint64_t a, uint64_t b)
{
return (a < b);
}
int int
i64_ugt(uint64_t a, uint64_t b) i64_ugt(uint64_t a, uint64_t b)
{ {
@ -54,6 +88,26 @@ i64_neq_select(int64_t a, int64_t b, int64_t c, int64_t d)
return ((a != b) ? c : d); return ((a != b) ? c : d);
} }
int64_t
i64_gt_select(int64_t a, int64_t b, int64_t c, int64_t d) {
return ((a > b) ? c : d);
}
int64_t
i64_le_select(int64_t a, int64_t b, int64_t c, int64_t d) {
return ((a <= b) ? c : d);
}
int64_t
i64_ge_select(int64_t a, int64_t b, int64_t c, int64_t d) {
return ((a >= b) ? c : d);
}
int64_t
i64_lt_select(int64_t a, int64_t b, int64_t c, int64_t d) {
return ((a < b) ? c : d);
}
uint64_t uint64_t
i64_ugt_select(uint64_t a, uint64_t b, uint64_t c, uint64_t d) i64_ugt_select(uint64_t a, uint64_t b, uint64_t c, uint64_t d)
{ {
@ -66,6 +120,16 @@ i64_ule_select(uint64_t a, uint64_t b, uint64_t c, uint64_t d)
return ((a <= b) ? c : d); return ((a <= b) ? c : d);
} }
uint64_t
i64_uge_select(uint64_t a, uint64_t b, uint64_t c, uint64_t d) {
return ((a >= b) ? c : d);
}
uint64_t
i64_ult_select(uint64_t a, uint64_t b, uint64_t c, uint64_t d) {
return ((a < b) ? c : d);
}
/* ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- */ /* ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- */
struct harness_int64_pred { struct harness_int64_pred {
@ -107,61 +171,131 @@ struct uint64_pred_s {
/* ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- */ /* ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- */
struct harness_int64_pred int64_tests_eq[] = { struct harness_int64_pred int64_tests_eq[] = {
{"a %s a", &a, &a, &c, &d, TRUE_VAL, &c}, {"a %s a", &tval_a, &tval_a, &tval_c, &tval_d, TRUE_VAL, &tval_c},
{"a %s b", &a, &b, &c, &d, FALSE_VAL, &d}, {"a %s b", &tval_a, &tval_b, &tval_c, &tval_d, FALSE_VAL, &tval_d},
{"a %s c", &a, &c, &c, &d, FALSE_VAL, &d}, {"a %s c", &tval_a, &tval_c, &tval_c, &tval_d, FALSE_VAL, &tval_d},
{"d %s e", &d, &e, &c, &d, FALSE_VAL, &d}, {"d %s e", &tval_d, &tval_e, &tval_c, &tval_d, FALSE_VAL, &tval_d},
{"e %s e", &e, &e, &c, &d, TRUE_VAL, &c} {"e %s e", &tval_e, &tval_e, &tval_c, &tval_d, TRUE_VAL, &tval_c}
}; };
struct harness_int64_pred int64_tests_neq[] = { struct harness_int64_pred int64_tests_neq[] = {
{"a %s a", &a, &a, &c, &d, FALSE_VAL, &d}, {"a %s a", &tval_a, &tval_a, &tval_c, &tval_d, FALSE_VAL, &tval_d},
{"a %s b", &a, &b, &c, &d, TRUE_VAL, &c}, {"a %s b", &tval_a, &tval_b, &tval_c, &tval_d, TRUE_VAL, &tval_c},
{"a %s c", &a, &c, &c, &d, TRUE_VAL, &c}, {"a %s c", &tval_a, &tval_c, &tval_c, &tval_d, TRUE_VAL, &tval_c},
{"d %s e", &d, &e, &c, &d, TRUE_VAL, &c}, {"d %s e", &tval_d, &tval_e, &tval_c, &tval_d, TRUE_VAL, &tval_c},
{"e %s e", &e, &e, &c, &d, FALSE_VAL, &d} {"e %s e", &tval_e, &tval_e, &tval_c, &tval_d, FALSE_VAL, &tval_d}
};
struct harness_int64_pred int64_tests_sgt[] = {
{"a %s a", &tval_a, &tval_a, &tval_c, &tval_d, FALSE_VAL, &tval_d},
{"a %s b", &tval_a, &tval_b, &tval_c, &tval_d, FALSE_VAL, &tval_d},
{"a %s c", &tval_a, &tval_c, &tval_c, &tval_d, TRUE_VAL, &tval_c},
{"d %s e", &tval_d, &tval_e, &tval_c, &tval_d, TRUE_VAL, &tval_c},
{"e %s e", &tval_e, &tval_e, &tval_c, &tval_d, FALSE_VAL, &tval_d}
};
struct harness_int64_pred int64_tests_sle[] = {
{"a %s a", &tval_a, &tval_a, &tval_c, &tval_d, TRUE_VAL, &tval_c},
{"a %s b", &tval_a, &tval_b, &tval_c, &tval_d, TRUE_VAL, &tval_c},
{"a %s c", &tval_a, &tval_c, &tval_c, &tval_d, FALSE_VAL, &tval_d},
{"d %s e", &tval_d, &tval_e, &tval_c, &tval_d, FALSE_VAL, &tval_d},
{"e %s e", &tval_e, &tval_e, &tval_c, &tval_d, TRUE_VAL, &tval_c}
};
struct harness_int64_pred int64_tests_sge[] = {
{"a %s a", &tval_a, &tval_a, &tval_c, &tval_d, TRUE_VAL, &tval_c},
{"a %s b", &tval_a, &tval_b, &tval_c, &tval_d, FALSE_VAL, &tval_d},
{"a %s c", &tval_a, &tval_c, &tval_c, &tval_d, TRUE_VAL, &tval_c},
{"d %s e", &tval_d, &tval_e, &tval_c, &tval_d, TRUE_VAL, &tval_c},
{"e %s e", &tval_e, &tval_e, &tval_c, &tval_d, TRUE_VAL, &tval_c}
};
struct harness_int64_pred int64_tests_slt[] = {
{"a %s a", &tval_a, &tval_a, &tval_c, &tval_d, FALSE_VAL, &tval_d},
{"a %s b", &tval_a, &tval_b, &tval_c, &tval_d, TRUE_VAL, &tval_c},
{"a %s c", &tval_a, &tval_c, &tval_c, &tval_d, FALSE_VAL, &tval_d},
{"d %s e", &tval_d, &tval_e, &tval_c, &tval_d, FALSE_VAL, &tval_d},
{"e %s e", &tval_e, &tval_e, &tval_c, &tval_d, FALSE_VAL, &tval_d}
}; };
struct int64_pred_s int64_preds[] = { struct int64_pred_s int64_preds[] = {
{"eq", i64_eq, i64_eq_select, {"eq", i64_eq, i64_eq_select,
int64_tests_eq, ARR_SIZE(int64_tests_eq)}, int64_tests_eq, ARR_SIZE(int64_tests_eq)},
{"neq", i64_neq, i64_neq_select, {"neq", i64_neq, i64_neq_select,
int64_tests_neq, ARR_SIZE(int64_tests_neq)} int64_tests_neq, ARR_SIZE(int64_tests_neq)},
{"gt", i64_gt, i64_gt_select,
int64_tests_sgt, ARR_SIZE(int64_tests_sgt)},
{"le", i64_le, i64_le_select,
int64_tests_sle, ARR_SIZE(int64_tests_sle)},
{"ge", i64_ge, i64_ge_select,
int64_tests_sge, ARR_SIZE(int64_tests_sge)},
{"lt", i64_lt, i64_lt_select,
int64_tests_slt, ARR_SIZE(int64_tests_slt)}
}; };
/* ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- */ /* ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~- */
struct harness_uint64_pred uint64_tests_ugt[] = { struct harness_uint64_pred uint64_tests_ugt[] = {
{"a %s a", (uint64_t *) &a, (uint64_t *) &a, (uint64_t *) &c, {"a %s a", (uint64_t *) &tval_a, (uint64_t *) &tval_a, (uint64_t *) &tval_c,
(uint64_t *) &d, FALSE_VAL, (uint64_t *) &d}, (uint64_t *) &tval_d, FALSE_VAL, (uint64_t *) &tval_d},
{"a %s b", (uint64_t *) &a, (uint64_t *) &b, (uint64_t *) &c, {"a %s b", (uint64_t *) &tval_a, (uint64_t *) &tval_b, (uint64_t *) &tval_c,
(uint64_t *) &d, FALSE_VAL, (uint64_t *) &d }, (uint64_t *) &tval_d, FALSE_VAL, (uint64_t *) &tval_d },
{"a %s c", (uint64_t *) &a, (uint64_t *) &c, (uint64_t *) &c, {"a %s c", (uint64_t *) &tval_a, (uint64_t *) &tval_c, (uint64_t *) &tval_c,
(uint64_t *) &d, TRUE_VAL, (uint64_t *) &c }, (uint64_t *) &tval_d, TRUE_VAL, (uint64_t *) &tval_c },
{"d %s e", (uint64_t *) &d, (uint64_t *) &e, (uint64_t *) &c, {"d %s e", (uint64_t *) &tval_d, (uint64_t *) &tval_e, (uint64_t *) &tval_c,
(uint64_t *) &d, TRUE_VAL, (uint64_t *) &c }, (uint64_t *) &tval_d, TRUE_VAL, (uint64_t *) &tval_c },
{"e %s e", (uint64_t *) &e, (uint64_t *) &e, (uint64_t *) &c, {"e %s e", (uint64_t *) &tval_e, (uint64_t *) &tval_e, (uint64_t *) &tval_c,
(uint64_t *) &d, FALSE_VAL, (uint64_t *) &d } (uint64_t *) &tval_d, FALSE_VAL, (uint64_t *) &tval_d }
}; };
struct harness_uint64_pred uint64_tests_ule[] = { struct harness_uint64_pred uint64_tests_ule[] = {
{"a %s a", (uint64_t *) &a, (uint64_t *) &a, (uint64_t *) &c, {"a %s a", (uint64_t *) &tval_a, (uint64_t *) &tval_a, (uint64_t *) &tval_c,
(uint64_t *) &d, TRUE_VAL, (uint64_t *) &c}, (uint64_t *) &tval_d, TRUE_VAL, (uint64_t *) &tval_c},
{"a %s b", (uint64_t *) &a, (uint64_t *) &b, (uint64_t *) &c, {"a %s b", (uint64_t *) &tval_a, (uint64_t *) &tval_b, (uint64_t *) &tval_c,
(uint64_t *) &d, TRUE_VAL, (uint64_t *) &c}, (uint64_t *) &tval_d, TRUE_VAL, (uint64_t *) &tval_c},
{"a %s c", (uint64_t *) &a, (uint64_t *) &c, (uint64_t *) &c, {"a %s c", (uint64_t *) &tval_a, (uint64_t *) &tval_c, (uint64_t *) &tval_c,
(uint64_t *) &d, FALSE_VAL, (uint64_t *) &d}, (uint64_t *) &tval_d, FALSE_VAL, (uint64_t *) &tval_d},
{"d %s e", (uint64_t *) &d, (uint64_t *) &e, (uint64_t *) &c, {"d %s e", (uint64_t *) &tval_d, (uint64_t *) &tval_e, (uint64_t *) &tval_c,
(uint64_t *) &d, FALSE_VAL, (uint64_t *) &d}, (uint64_t *) &tval_d, FALSE_VAL, (uint64_t *) &tval_d},
{"e %s e", (uint64_t *) &e, (uint64_t *) &e, (uint64_t *) &c, {"e %s e", (uint64_t *) &tval_e, (uint64_t *) &tval_e, (uint64_t *) &tval_c,
(uint64_t *) &d, TRUE_VAL, (uint64_t *) &c} (uint64_t *) &tval_d, TRUE_VAL, (uint64_t *) &tval_c}
};
struct harness_uint64_pred uint64_tests_uge[] = {
{"a %s a", (uint64_t *) &tval_a, (uint64_t *) &tval_a, (uint64_t *) &tval_c,
(uint64_t *) &tval_d, TRUE_VAL, (uint64_t *) &tval_c},
{"a %s b", (uint64_t *) &tval_a, (uint64_t *) &tval_b, (uint64_t *) &tval_c,
(uint64_t *) &tval_d, FALSE_VAL, (uint64_t *) &tval_d},
{"a %s c", (uint64_t *) &tval_a, (uint64_t *) &tval_c, (uint64_t *) &tval_c,
(uint64_t *) &tval_d, TRUE_VAL, (uint64_t *) &tval_c},
{"d %s e", (uint64_t *) &tval_d, (uint64_t *) &tval_e, (uint64_t *) &tval_c,
(uint64_t *) &tval_d, TRUE_VAL, (uint64_t *) &tval_c},
{"e %s e", (uint64_t *) &tval_e, (uint64_t *) &tval_e, (uint64_t *) &tval_c,
(uint64_t *) &tval_d, TRUE_VAL, (uint64_t *) &tval_c}
};
struct harness_uint64_pred uint64_tests_ult[] = {
{"a %s a", (uint64_t *) &tval_a, (uint64_t *) &tval_a, (uint64_t *) &tval_c,
(uint64_t *) &tval_d, FALSE_VAL, (uint64_t *) &tval_d},
{"a %s b", (uint64_t *) &tval_a, (uint64_t *) &tval_b, (uint64_t *) &tval_c,
(uint64_t *) &tval_d, TRUE_VAL, (uint64_t *) &tval_c},
{"a %s c", (uint64_t *) &tval_a, (uint64_t *) &tval_c, (uint64_t *) &tval_c,
(uint64_t *) &tval_d, FALSE_VAL, (uint64_t *) &tval_d},
{"d %s e", (uint64_t *) &tval_d, (uint64_t *) &tval_e, (uint64_t *) &tval_c,
(uint64_t *) &tval_d, FALSE_VAL, (uint64_t *) &tval_d},
{"e %s e", (uint64_t *) &tval_e, (uint64_t *) &tval_e, (uint64_t *) &tval_c,
(uint64_t *) &tval_d, FALSE_VAL, (uint64_t *) &tval_d}
}; };
struct uint64_pred_s uint64_preds[] = { struct uint64_pred_s uint64_preds[] = {
{"ugt", i64_ugt, i64_ugt_select, {"ugt", i64_ugt, i64_ugt_select,
uint64_tests_ugt, ARR_SIZE(uint64_tests_ugt)}, uint64_tests_ugt, ARR_SIZE(uint64_tests_ugt)},
{"ule", i64_ule, i64_ule_select, {"ule", i64_ule, i64_ule_select,
uint64_tests_ule, ARR_SIZE(uint64_tests_ule)} uint64_tests_ule, ARR_SIZE(uint64_tests_ule)},
{"uge", i64_uge, i64_uge_select,
uint64_tests_uge, ARR_SIZE(uint64_tests_uge)},
{"ult", i64_ult, i64_ult_select,
uint64_tests_ult, ARR_SIZE(uint64_tests_ult)}
}; };
int int
@ -289,12 +423,12 @@ main(void)
const char *something_failed = " %d tests failed.\n"; const char *something_failed = " %d tests failed.\n";
const char *all_tests_passed = " All tests passed.\n"; const char *all_tests_passed = " All tests passed.\n";
printf("a = %16lld (0x%016llx)\n", a, a); printf("a = %16lld (0x%016llx)\n", tval_a, tval_a);
printf("b = %16lld (0x%016llx)\n", b, b); printf("b = %16lld (0x%016llx)\n", tval_b, tval_b);
printf("c = %16lld (0x%016llx)\n", c, c); printf("c = %16lld (0x%016llx)\n", tval_c, tval_c);
printf("d = %16lld (0x%016llx)\n", d, d); printf("d = %16lld (0x%016llx)\n", tval_d, tval_d);
printf("e = %16lld (0x%016llx)\n", e, e); printf("e = %16lld (0x%016llx)\n", tval_e, tval_e);
printf("f = %16lld (0x%016llx)\n", f, f); printf("f = %16lld (0x%016llx)\n", tval_f, tval_f);
printf("----------------------------------------\n"); printf("----------------------------------------\n");
for (i = 0; i < ARR_SIZE(int64_preds); ++i) { for (i = 0; i < ARR_SIZE(int64_preds); ++i) {
@ -319,22 +453,22 @@ main(void)
printf("----------------------------------------\n"); printf("----------------------------------------\n");
} }
printf("a = 0x%016llx\n", a); printf("a = 0x%016llx\n", tval_a);
printf("i64_shl_const(a) = 0x%016llx\n", i64_shl_const(a)); printf("i64_shl_const(a) = 0x%016llx\n", i64_shl_const(tval_a));
printf("i64_shl(a) = 0x%016llx\n", i64_shl(a, 10)); printf("i64_shl(a) = 0x%016llx\n", i64_shl(tval_a, 10));
printf("i64_srl_const(a) = 0x%016llx\n", i64_srl_const(a)); printf("i64_srl_const(a) = 0x%016llx\n", i64_srl_const(tval_a));
printf("i64_srl(a) = 0x%016llx\n", i64_srl(a, 10)); printf("i64_srl(a) = 0x%016llx\n", i64_srl(tval_a, 10));
printf("i64_sra_const(a) = 0x%016llx\n", i64_sra_const(a)); printf("i64_sra_const(a) = 0x%016llx\n", i64_sra_const(tval_a));
printf("i64_sra(a) = 0x%016llx\n", i64_sra(a, 10)); printf("i64_sra(a) = 0x%016llx\n", i64_sra(tval_a, 10));
printf("----------------------------------------\n"); printf("----------------------------------------\n");
printf("f = 0x%016llx\n", f); printf("f = 0x%016llx\n", tval_f);
printf("i64_shl_const(f) = 0x%016llx\n", i64_shl_const(f)); printf("i64_shl_const(f) = 0x%016llx\n", i64_shl_const(tval_f));
printf("i64_shl(f) = 0x%016llx\n", i64_shl(f, 10)); printf("i64_shl(f) = 0x%016llx\n", i64_shl(tval_f, 10));
printf("i64_srl_const(f) = 0x%016llx\n", i64_srl_const(f)); printf("i64_srl_const(f) = 0x%016llx\n", i64_srl_const(tval_f));
printf("i64_srl(f) = 0x%016llx\n", i64_srl(f, 10)); printf("i64_srl(f) = 0x%016llx\n", i64_srl(tval_f, 10));
printf("i64_sra_const(f) = 0x%016llx\n", i64_sra_const(f)); printf("i64_sra_const(f) = 0x%016llx\n", i64_sra_const(tval_f));
printf("i64_sra(f) = 0x%016llx\n", i64_sra(f, 10)); printf("i64_sra(f) = 0x%016llx\n", i64_sra(tval_f, 10));
printf("----------------------------------------\n"); printf("----------------------------------------\n");
return 0; return 0;