Skip to content

Commit 27aea17

Browse files
committed
[TypePromotion] Don't treat bitcast as a Source
This removes BitCasts from isSource in Type Promotion, as I don't believe they need to be treated as Sources. They will usually be from floats or hoisted constants, where constants will be handled already. This fixes llvm#62513, but didn't otherwise cause any differences in the tests I ran. Differential Revision: https://reviews.llvm.org/D152112
1 parent c2926c6 commit 27aea17

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

llvm/lib/CodeGen/TypePromotion.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,6 @@ bool TypePromotionImpl::isSource(Value *V) {
235235
return true;
236236
else if (isa<LoadInst>(V))
237237
return true;
238-
else if (isa<BitCastInst>(V))
239-
return true;
240238
else if (auto *Call = dyn_cast<CallInst>(V))
241239
return Call->hasRetAttr(Attribute::AttrKind::ZExt);
242240
else if (auto *Trunc = dyn_cast<TruncInst>(V))

llvm/test/Transforms/TypePromotion/ARM/casts.ll

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,9 @@ define i16 @bitcast_i16(i16 zeroext %arg0, i16 zeroext %arg1) {
248248
; CHECK-LABEL: @bitcast_i16(
249249
; CHECK-NEXT: entry:
250250
; CHECK-NEXT: [[TMP0:%.*]] = zext i16 [[ARG0:%.*]] to i32
251-
; CHECK-NEXT: [[CAST:%.*]] = bitcast i16 12345 to i16
252-
; CHECK-NEXT: [[TMP1:%.*]] = zext i16 [[CAST]] to i32
251+
; CHECK-NEXT: [[CAST:%.*]] = bitcast i32 12345 to i32
253252
; CHECK-NEXT: [[ADD:%.*]] = add nuw i32 [[TMP0]], 1
254-
; CHECK-NEXT: [[CMP:%.*]] = icmp ule i32 [[ADD]], [[TMP1]]
253+
; CHECK-NEXT: [[CMP:%.*]] = icmp ule i32 [[ADD]], [[CAST]]
255254
; CHECK-NEXT: [[RES:%.*]] = select i1 [[CMP]], i16 [[ARG1:%.*]], i16 32657
256255
; CHECK-NEXT: ret i16 [[RES]]
257256
;
@@ -1105,3 +1104,30 @@ exit:
11051104
%res = phi float [ 0.0, %entry ], [ %div, %if.end ]
11061105
ret float %res
11071106
}
1107+
1108+
define i32 @bitcasted() {
1109+
; CHECK-LABEL: @bitcasted(
1110+
; CHECK-NEXT: entry:
1111+
; CHECK-NEXT: br label [[LOOP:%.*]]
1112+
; CHECK: loop:
1113+
; CHECK-NEXT: [[T157_PH:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[T145_OLD:%.*]], [[LATCH:%.*]] ]
1114+
; CHECK-NEXT: [[EXT:%.*]] = zext i32 [[T157_PH]] to i64
1115+
; CHECK-NEXT: br label [[LATCH]]
1116+
; CHECK: latch:
1117+
; CHECK-NEXT: [[T145_OLD]] = bitcast i32 8 to i32
1118+
; CHECK-NEXT: [[T146_OLD:%.*]] = bitcast i32 [[T145_OLD]] to i32
1119+
; CHECK-NEXT: br label [[LOOP]]
1120+
;
1121+
entry:
1122+
br label %loop
1123+
1124+
loop:
1125+
%t157.ph = phi i32 [ 0, %entry ], [ %t145.old, %latch ]
1126+
%ext = zext i32 %t157.ph to i64
1127+
br label %latch
1128+
1129+
latch:
1130+
%t145.old = bitcast i32 8 to i32
1131+
%t146.old = bitcast i32 %t145.old to i32
1132+
br label %loop
1133+
}

0 commit comments

Comments
 (0)