[PATCH] D71833: [PowerPC] Fix some bugs of the rlwinm folding
ChenZheng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 23 07:45:15 PST 2019
shchenz added a comment.
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?
================
Comment at: llvm/lib/Target/PowerPC/PPCMIPeephole.cpp:904
if (MI.getOpcode() == PPC::RLWINM || MI.getOpcode() == PPC::RLWINM8) {
+ if (MRI->hasOneNonDBGUse(FoldingReg)) {
+ ToErase = SrcMI;
----------------
We can delete the SrcMI only if it is not a record form?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71833/new/
https://reviews.llvm.org/D71833
More information about the llvm-commits
mailing list