https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78748
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Created attachment 40292 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=40292&action=edit gcc7-pr78748.patch Untested fix (though, I don't have a quick setup to bootstrap/regtest it in the next week or so). The bug seems to be that if reg_overlap_mentioned_p returns true in between op0 and op2, perhaps better testcase for that would be: /* PR target/78748 */ void foo (int *p, int *q) { *q = *p & ~*q; } void bar (int *p, int *q) { *q = ~*p & *q; } where indeed there is a potential overlap in between the two, then the op1 & op2 result is forced into a pseudo, but if op0 is a MEM that matched op1, that means the xor violates s390_logical_operator_ok_p, as the destination does not match any of the operands, even when it is a memory. The patch makes sure it is either not a MEM, or matches op2, which appears in both instructions.