[PATCH] D64119: [PowerPC] Support constraint code "ww"

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 3 21:30:05 PDT 2019


MaskRay marked an inline comment as done.
MaskRay added a comment.

  float ws_float(float x, float y) {
    __asm__ ("xsadddp %0, %1, %2" : "=ws"(x) : "ws"(x), "ws"(y));
    return x;
  }
  float ww_float(float x, float y) {
    __asm__ ("xsadddp %0, %1, %2" : "=ww"(x) : "ww"(x), "ww"(y));
    return x;
  }
  
  double ws_double(double x, double y) {
    __asm__ ("xsadddp %0, %1, %2" : "=ws"(x) : "ws"(x), "ws"(y));
    return x;
  }
  double ww_double(double x, double y) {
    __asm__ ("xsadddp %0, %1, %2" : "=ww"(x) : "ww"(x), "ww"(y));
    return x;
  }



  % powerpc64le-linux-gnu-gcc -O2 a.c -S -o - | grep xsadd
          xsadddp 1, 1, 2
          xsadddp 1, 1, 2
          xsadddp 1, 1, 2
          xsadddp 1, 1, 2



  float scalar_ww_float(float x, float y) {
    __asm__ ("fadds %0, %1, %2" : "=ww"(x) : "ww"(x), "ww"(y));
    return x;
  }
  float scalar_ws_float(float x, float y) {
    __asm__ ("fadds %0, %1, %2" : "=ws"(x) : "ws"(x), "ws"(y));
    return x;
  }
  double scalar_ww_double(double x, double y) {
    __asm__ ("fadds %0, %1, %2" : "=ww"(x) : "ww"(x), "ww"(y));
    return x;
  }
  double scalar_ws_double(double x, double y) {
    __asm__ ("fadds %0, %1, %2" : "=ws"(x) : "ws"(x), "ws"(y));
    return x;
  }



  % powerpc64le-linux-gnu-gcc -O2 a.c -S -o - | grep fadds
          fadds 1, 1, 2
          fadds 1, 1, 2
          fadds 1, 1, 2
          fadds 1, 1, 2



================
Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:14080
     return std::make_pair(0U, &PPC::VSRCRegClass);
-  } else if (Constraint == "ws" && Subtarget.hasVSX()) {
+  } else if ((Constraint == "ws" || Constraint == "ww") && Subtarget.hasVSX()) {
     if (VT == MVT::f32 && Subtarget.hasP8Vector())
----------------
jsji wrote:
> MaskRay wrote:
> > jsji wrote:
> > > Should we exclude `FP` for `ws` and return `VFRCRegClass` instead of `VSFRCRegClass` ?
> > Can you elaborate on what I should do? I'm not familiar with the register info stuff...
> `VSFRC` contains both `F8RC` and `VFRC`. `F8RC` is FP.
> So if `ws` can NOT use FP, then we should not use `VSFRC`.
> 
> However, if `ws` can use `FP` as well as you found in later GCC experiments, then we don't need to do this.
```
float ws_float(float x, float y) {
  __asm__ ("xsadddp %0, %1, %2" : "=ws"(x) : "ws"(x), "ws"(y));
  return x;
}
float ww_float(float x, float y) {
  __asm__ ("xsadddp %0, %1, %2" : "=ww"(x) : "ww"(x), "ww"(y));
  return x;
}

double ws_double(double x, double y) {
  __asm__ ("xsadddp %0, %1, %2" : "=ws"(x) : "ws"(x), "ws"(y));
  return x;
}
double ww_double(double x, double y) {
  __asm__ ("xsadddp %0, %1, %2" : "=ww"(x) : "ww"(x), "ww"(y));
  return x;
}
```

```
% powerpc64le-linux-gnu-gcc -O2 a.c -S -o - | grep xsadd
        xsadddp 1, 1, 2
        xsadddp 1, 1, 2
        xsadddp 1, 1, 2
        xsadddp 1, 1, 2
```




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64119/new/

https://reviews.llvm.org/D64119





More information about the cfe-commits mailing list