[llvm-commits] [llvm] r105741 - /llvm/trunk/lib/CodeGen/OptimizeExts.cpp
Bill Wendling
isanbard at gmail.com
Wed Jun 9 12:00:55 PDT 2010
Author: void
Date: Wed Jun 9 14:00:55 2010
New Revision: 105741
URL: http://llvm.org/viewvc/llvm-project?rev=105741&view=rev
Log:
It's an error to translate this:
%reg1025 = <sext> %reg1024
...
%reg1026 = SUBREG_TO_REG 0, %reg1024, 4
into this:
%reg1025 = <sext> %reg1024
...
%reg1027 = EXTRACT_SUBREG %reg1025, 4
%reg1026 = SUBREG_TO_REG 0, %reg1027, 4
The problem here is that SUBREG_TO_REG is there to assert that an implicit zext
occurs. It doesn't insert a zext instruction. If we allow the EXTRACT_SUBREG
here, it will give us the value after the <sext>, not the original value of
%reg1024 before <sext>.
Modified:
llvm/trunk/lib/CodeGen/OptimizeExts.cpp
Modified: llvm/trunk/lib/CodeGen/OptimizeExts.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/OptimizeExts.cpp?rev=105741&r1=105740&r2=105741&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/OptimizeExts.cpp (original)
+++ llvm/trunk/lib/CodeGen/OptimizeExts.cpp Wed Jun 9 14:00:55 2010
@@ -118,6 +118,26 @@
continue;
}
+ // It's an error to translate this:
+ //
+ // %reg1025 = <sext> %reg1024
+ // ...
+ // %reg1026 = SUBREG_TO_REG 0, %reg1024, 4
+ //
+ // into this:
+ //
+ // %reg1025 = <sext> %reg1024
+ // ...
+ // %reg1027 = EXTRACT_SUBREG %reg1025, 4
+ // %reg1026 = SUBREG_TO_REG 0, %reg1027, 4
+ //
+ // The problem here is that SUBREG_TO_REG is there to assert that an
+ // implicit zext occurs. It doesn't insert a zext instruction. If we allow
+ // the EXTRACT_SUBREG here, it will give us the value after the <sext>,
+ // not the original value of %reg1024 before <sext>.
+ if (UseMI->getOpcode() == TargetOpcode::SUBREG_TO_REG)
+ continue;
+
MachineBasicBlock *UseMBB = UseMI->getParent();
if (UseMBB == MBB) {
// Local uses that come after the extension.
More information about the llvm-commits
mailing list