Skip to content

Commit d27b5e2

Browse files
wenju-heigcbot
authored andcommitted
Fix PromoteInt8Type hang when promoteInst is ptrtoint
A ptrtoint instruction is added as candidate to be promoted, however, it isn't handled in the while loop of promoteInstructions. This causes the loop hanging later when processing its user instruction, which is also to be promoted.
1 parent 83d83c6 commit d27b5e2

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

IGC/Compiler/CISACodeGen/PromoteInt8Type.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,7 @@ void PromoteInt8Type::promoteInstructions()
663663
break;
664664
}
665665
case Instruction::BitCast:
666+
case Instruction::PtrToInt:
666667
case Instruction::Load:
667668
case Instruction::Trunc:
668669
case Instruction::Call:

IGC/Compiler/tests/PromoteInt8Type/basic.ll

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,15 @@ define i1 @test_icmp(i8 %src1, i8 %src2) {
163163
ret i1 %1
164164
}
165165

166+
define i8 @test_ptrtoint(i8* %src) {
167+
; CHECK-LABEL: @test_ptrtoint(
168+
; CHECK: [[P2B:%.*]] = ptrtoint i8* %src to i8
169+
; CHECK: [[B2S:%.*]] = sext i8 [[P2B]] to i16
170+
; CHECK: [[AND:%.*]] = and i16 [[B2S]], 7
171+
; CHECK: [[TRUNC:%.*]] = trunc i16 [[AND]] to i8
172+
; CHECK: ret i8 [[TRUNC]]
173+
174+
%1 = ptrtoint i8* %src to i8
175+
%2 = and i8 %1, 7
176+
ret i8 %2
177+
}

0 commit comments

Comments
 (0)