llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

IfConversion adds Undef flag on use even if reg is live

Open JonPsson opened this issue 10 years ago • 2 comments

Bugzilla Link 27987
Resolution FIXED
Resolved on Jun 23, 2016 04:00
Version trunk
OS Linux
CC @hfinkel

Extended Description

IfConversion will call UpdatePredRedefs() after an MI has been predicated by target, to update the liveness tracking, and also to add implicit use operands on MI (for the register that has become conditionally def:ed). IfConversion was always adding these use operands with the Undef flag, which caused later passes to get into trouble, since that register will incorrectly be considered dead before MI.

This was discovered with SystemZ, where the following transformation would take place where it shouldn't:

%R4L = L %R15D, 440, %noreg; mem:LD4[FixedStack5] %R4H = IIHF 1000 %R4L = LOCR %R10L, 14, 10, %CC, %R4L<imp-use,undef>

%R4L = L %R15D, 440, %noreg; mem:LD4[FixedStack5] %R4D = LLIHL 1000 %R4L = LOCR %R10L, 14, 10, %CC, %R4L<imp-use,undef>

LivePhysRegs thinks during the SystemZShortenInst pass that %R4L is dead at IIHF and replaces it with an LLIHL wich overwrites %R4L. The LOCR (Load On Condition Register) produced by IfConversion, has the bad undef flag.

For a proposed bugfix, see http://reviews.llvm.org/D20907

JonPsson avatar Jun 03 '16 09:06 JonPsson

r273545

JonPsson avatar Jun 23 '16 11:06 JonPsson

assigned to @JonPsson

JonPsson avatar Jun 03 '16 09:06 JonPsson