Move a sign-extend or a zero-extend of a load to the same basic block as the
authorBob Wilson <bob.wilson@apple.com>
Tue, 21 Sep 2010 21:54:27 +0000 (21:54 +0000)
committerBob Wilson <bob.wilson@apple.com>
Tue, 21 Sep 2010 21:54:27 +0000 (21:54 +0000)
load when the type of the load is not legal, even if truncates are not free.
The load is going to be legalized to an extending load anyway.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114488 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/CodeGenPrepare.cpp

index 0e05a26d243b860b87b9088591eb7d0bca81061b..526107c977092a7a932e56e94d396268b78cfdd0 100644 (file)
@@ -772,7 +772,8 @@ bool CodeGenPrepare::MoveExtToFormExtLoad(Instruction *I) {
   // If the load has other users and the truncate is not free, this probably
   // isn't worthwhile.
   if (!LI->hasOneUse() &&
-      TLI && !TLI->isTruncateFree(I->getType(), LI->getType()))
+      TLI && TLI->isTypeLegal(TLI->getValueType(LI->getType())) &&
+      !TLI->isTruncateFree(I->getType(), LI->getType()))
     return false;
 
   // Check whether the target supports casts folded into loads.