[llvm] 9ad3ca4 - Revert "[TypePromotion] Don't treat bitcast as a Source"

Paul Kirth via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 6 17:51:50 PDT 2023


Author: Paul Kirth
Date: 2023-06-07T00:51:20Z
New Revision: 9ad3ca4e9a310c1507578b1c8165cd61a9a45037

URL: https://github.com/llvm/llvm-project/commit/9ad3ca4e9a310c1507578b1c8165cd61a9a45037
DIFF: https://github.com/llvm/llvm-project/commit/9ad3ca4e9a310c1507578b1c8165cd61a9a45037.diff

LOG: Revert "[TypePromotion] Don't treat bitcast as a Source"

This reverts commit 27aea17fe061f9778bb1e8ff5fdf9fc0fb03abe1.
For details, see: https://reviews.llvm.org/D152112

Fuchsia CI failure: https://ci.chromium.org/ui/p/fuchsia/builders/toolchain.ci/clang-linux-arm64/b8779118297575483793/overview

Added: 
    

Modified: 
    llvm/lib/CodeGen/TypePromotion.cpp
    llvm/test/Transforms/TypePromotion/ARM/casts.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/TypePromotion.cpp b/llvm/lib/CodeGen/TypePromotion.cpp
index a6ec106f30f97..028ca7bc25d7b 100644
--- a/llvm/lib/CodeGen/TypePromotion.cpp
+++ b/llvm/lib/CodeGen/TypePromotion.cpp
@@ -235,6 +235,8 @@ bool TypePromotionImpl::isSource(Value *V) {
     return true;
   else if (isa<LoadInst>(V))
     return true;
+  else if (isa<BitCastInst>(V))
+    return true;
   else if (auto *Call = dyn_cast<CallInst>(V))
     return Call->hasRetAttr(Attribute::AttrKind::ZExt);
   else if (auto *Trunc = dyn_cast<TruncInst>(V))

diff  --git a/llvm/test/Transforms/TypePromotion/ARM/casts.ll b/llvm/test/Transforms/TypePromotion/ARM/casts.ll
index cd25347c095cb..3f0e545bda6ea 100644
--- a/llvm/test/Transforms/TypePromotion/ARM/casts.ll
+++ b/llvm/test/Transforms/TypePromotion/ARM/casts.ll
@@ -248,9 +248,10 @@ define i16 @bitcast_i16(i16 zeroext %arg0, i16 zeroext %arg1) {
 ; CHECK-LABEL: @bitcast_i16(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    [[TMP0:%.*]] = zext i16 [[ARG0:%.*]] to i32
-; CHECK-NEXT:    [[CAST:%.*]] = bitcast i32 12345 to i32
+; CHECK-NEXT:    [[CAST:%.*]] = bitcast i16 12345 to i16
+; CHECK-NEXT:    [[TMP1:%.*]] = zext i16 [[CAST]] to i32
 ; CHECK-NEXT:    [[ADD:%.*]] = add nuw i32 [[TMP0]], 1
-; CHECK-NEXT:    [[CMP:%.*]] = icmp ule i32 [[ADD]], [[CAST]]
+; CHECK-NEXT:    [[CMP:%.*]] = icmp ule i32 [[ADD]], [[TMP1]]
 ; CHECK-NEXT:    [[RES:%.*]] = select i1 [[CMP]], i16 [[ARG1:%.*]], i16 32657
 ; CHECK-NEXT:    ret i16 [[RES]]
 ;
@@ -1104,30 +1105,3 @@ exit:
   %res = phi float [ 0.0, %entry ], [ %div, %if.end ]
   ret float %res
 }
-
-define i32 @bitcasted() {
-; CHECK-LABEL: @bitcasted(
-; CHECK-NEXT:  entry:
-; CHECK-NEXT:    br label [[LOOP:%.*]]
-; CHECK:       loop:
-; CHECK-NEXT:    [[T157_PH:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[T145_OLD:%.*]], [[LATCH:%.*]] ]
-; CHECK-NEXT:    [[EXT:%.*]] = zext i32 [[T157_PH]] to i64
-; CHECK-NEXT:    br label [[LATCH]]
-; CHECK:       latch:
-; CHECK-NEXT:    [[T145_OLD]] = bitcast i32 8 to i32
-; CHECK-NEXT:    [[T146_OLD:%.*]] = bitcast i32 [[T145_OLD]] to i32
-; CHECK-NEXT:    br label [[LOOP]]
-;
-entry:
-  br label %loop
-
-loop:
-  %t157.ph = phi i32 [ 0, %entry ], [ %t145.old, %latch ]
-  %ext = zext i32 %t157.ph to i64
-  br label %latch
-
-latch:
-  %t145.old = bitcast i32 8 to i32
-  %t146.old = bitcast i32 %t145.old to i32
-  br label %loop
-}


        


More information about the llvm-commits mailing list