[PATCH] D71833: [PowerPC] Fix some bugs of the rlwinm folding
qshanz via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 23 18:31:04 PST 2019
steven.zhang added a comment.
In D71833#1794987 <https://reviews.llvm.org/D71833#1794987>, @shchenz wrote:
> Thanks for finding the bug in the testcases. I have modified them in NFC patch https://reviews.llvm.org/rG79b3325be0b016fdc1a2c55bce65ec9f1e5f4eb6
>
> Could you please help to be more specific about the invalid case in the description?
>
> Below c code gives a **valid** result:
>
> #include <stdio.h>
>
> #define rlwinm( output, input, sh, mb, me ) \
> __asm__( "rlwinm %0, %1, %2, %3, %4" \
> : "=r"(output) \
> : "r"(input), "i"(sh), "i"(mb), "i"(me) \
> : )
>
> int main()
> {
> unsigned long y,z,t ;
>
> int i = 0;
>
> for (unsigned x = 0; x < 4294967295; x++) {
> rlwinm( y, x, 27, 30, 10) ;
> rlwinm( z, y, 19, 0, 12);
> rlwinm(t, x, 14, 11, 12);
> if (z != t) {
> printf("0x%016lX -> 0x%016lX, 0x%016lX\n", x, y, z);
> printf("0x%016lX -> 0x%016lX\n", x, t);
> i = 100;
> break;
> }
> }
> if (i == 0)
> printf("valid\n");
> else
> printf("invalid\n");
> return 0;
> }
>
>
> So I guess
>
> %2:gprc = RLWINM %1:gprc, 27, 30, 10
> %3:gprc = RLWINM %2:gprc, 19, 0, 12
>
>
> should always be equal to
>
> %3:gprc = RLWINM %1, 14, 11, 12
>
>
> for type i32 and i64 also?
This is the bad transformation:
%1:g8rc = RLWINM8 %0:g8rc, 0, 16, 9
%2:g8rc = RLWINM8 killed %1:g8rc, 0, 0, 31
->
%2:g8rc = RLWINM8 %0:g8rc, 0, 16, 9
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71833/new/
https://reviews.llvm.org/D71833
More information about the llvm-commits
mailing list