[PATCH 1/1] Implement generic mad_sat

v2: Fix trailing whitespace
    Fix signed long overflow
    improve comment

v3: fix typo

Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>

v2: Fix trailing whitespace
    Fix signed long overflow
    improve comment

v3: fix typo

Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
---

Hi Aaron,
any luck running these on SI?

I just tested on SI. LGTM.

-Tom

I'm still getting:

LLVM ERROR: Cannot select: 0x1b1a5b0: i64 = and 0x1b1af90, 0x115bbc0
[ORD=19] [ID=83]
  0x1b1af90: i64 = any_extend 0x1b1bae8 [ORD=18] [ID=82]
    0x1b1bae8: i32 = and 0x11609d0, 0x115ce78 [ORD=18] [ID=80]
      0x11609d0: i32 = mul 0x1161cf8, 0x1b16508 [ORD=10] [ID=51]
        0x1161cf8: i32 = truncate 0x1b198b8 [ORD=10] [ID=37]
          0x1b198b8: i64,ch = CopyFromReg 0x1b1abe0:1, 0x1b19288 [ORD=4] [ID=32]
            0x1b19288: i64 = Register %vreg3 [ID=8]
        0x1b16508: i32 = truncate 0x115e098 [ORD=9] [ID=43]
          0x115e098: i64 = sra 0x1164e40, 0x115fff0 [ORD=5] [ID=35]
<snip>

Let me at least do a full clean + rebuild and then try again before pushing.

--Aaron

I'm still getting:

LLVM ERROR: Cannot select: 0x1b1a5b0: i64 = and 0x1b1af90, 0x115bbc0
[ORD=19] [ID=83]
  0x1b1af90: i64 = any_extend 0x1b1bae8 [ORD=18] [ID=82]
    0x1b1bae8: i32 = and 0x11609d0, 0x115ce78 [ORD=18] [ID=80]
      0x11609d0: i32 = mul 0x1161cf8, 0x1b16508 [ORD=10] [ID=51]
        0x1161cf8: i32 = truncate 0x1b198b8 [ORD=10] [ID=37]
          0x1b198b8: i64,ch = CopyFromReg 0x1b1abe0:1, 0x1b19288 [ORD=4] [ID=32]
            0x1b19288: i64 = Register %vreg3 [ID=8]
        0x1b16508: i32 = truncate 0x115e098 [ORD=9] [ID=43]
          0x115e098: i64 = sra 0x1164e40, 0x115fff0 [ORD=5] [ID=35]
<snip>

This is a bug in the backend. I have a local patch I will send to llvm-commits soon.

-Tom

With Tom's LLVM patch applied, the mad_sat long/ulong tests pass for
me on both evergreen (cedar) and SI (pitcairn).

I think we're good here.

--Aaron

With Tom's LLVM patch applied, the mad_sat long/ulong tests pass for
me on both evergreen (cedar) and SI (pitcairn).

I think we're good here.

Thanks to both of you. I pushed the patch.

jan