This is an archive of the discontinued LLVM Phabricator instance.

[SystemZ] Fix register ordering for BinaryRRF instructions
ClosedPublic

Authored by zhanjunl on May 16 2016, 3:21 PM.

Details

Summary

The ordering of registers in BinaryRRF instructions are wrong, and affects the copysign instruction (CPSDR). This results in the wrong magnitude and sign being set.

Diff Detail

Repository
rL LLVM

Event Timeline

zhanjunl updated this revision to Diff 57407.EditedMay 16 2016, 3:21 PM
zhanjunl retitled this revision from to [SystemZ] Fix register ordering for BinaryRRF instructions.
zhanjunl updated this object.
zhanjunl added reviewers: uweigand, kbarton.
zhanjunl added a subscriber: llvm-commits.

A simple testcase is:

#include <stdio.h>
#include <cmath>

double cpsdr(double a, double b) {
  return copysign(a,b);
}

double a = 1.0;
double b = -2.0;

int main () {
  printf("ret is %lf\n", cpsdr(a, b));
  return 0;
}

The expected result is -1.0, but the return of clang is 2.0.

uweigand accepted this revision.May 17 2016, 5:11 AM
uweigand edited edge metadata.

LGTM, thanks!

This revision is now accepted and ready to land.May 17 2016, 5:11 AM
This revision was automatically updated to reflect the committed changes.