This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] [Altivec] Use signed comparison for vec_all_* and vec_any_* interfaces that compare vector bool types with vector signed types
ClosedPublic

Authored by bmahjour on Jul 8 2021, 3:24 PM.

Details

Summary

We are currently being inconsistent in using signed vs unsigned comparisons for vec_all_* and vec_any_* interfaces that use vector bool types. For example we use signed comparison for vec_all_ge(vector signed char, vector bool char) but unsigned comparison for when the arguments are swapped. GCC and XL use signed comparison instead. This patch makes clang consistent with itself and with XL and GCC.

Example:

#include <stdio.h>
#include <altivec.h>
int main() {
  vector signed char a = {0,0,0,0,0,0,0xA3,0,0,0x89,0,0,0xA4,0,0,0};
  vector bool char b = {0,0,0,0,0,0,0xF3,0,0,0x61,0,0,0xAE,0,0,0};
  printf(" a >= b : %d\n b >= a : %d\n", vec_all_ge(a, b), vec_all_ge(b, a));
  return 0;
}

currently produces

a >= b : 0
b >= a : 0

with this patch we get:

a >= b : 0
b >= a : 1

Diff Detail

Event Timeline

bmahjour created this revision.Jul 8 2021, 3:24 PM
bmahjour requested review of this revision.Jul 8 2021, 3:24 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 8 2021, 3:24 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
bmahjour edited the summary of this revision. (Show Details)Jul 8 2021, 3:25 PM
nemanjai accepted this revision.Jul 10 2021, 8:51 AM

LGTM. Thanks.

This revision is now accepted and ready to land.Jul 10 2021, 8:51 AM
This revision was landed with ongoing or failed builds.Jul 12 2021, 8:47 AM
This revision was automatically updated to reflect the committed changes.