Skip to content

Commit c012a9c

Browse files
committed
!fixup use m_c_Add
1 parent 5ed4d71 commit c012a9c

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2077,7 +2077,7 @@ Instruction *InstCombinerImpl::visitIntToPtr(IntToPtrInst &CI) {
20772077
Value *Base;
20782078
Value *Offset;
20792079
if (match(CI.getOperand(0),
2080-
m_Add(m_PtrToIntSameSize(DL, m_Value(Base)), m_Value(Offset))) &&
2080+
m_c_Add(m_PtrToIntSameSize(DL, m_Value(Base)), m_Value(Offset))) &&
20812081
CI.getType()->getPointerAddressSpace() ==
20822082
Base->getType()->getPointerAddressSpace() &&
20832083
all_of(CI.users(), IsaPred<ICmpInst>)) {

llvm/test/Transforms/InstCombine/fold-bin-operand.ll

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,8 @@ define i1 @inttoptr_add_ptrtoint_used_by_single_icmp(ptr %src, ptr %p2) {
4545

4646
define i1 @inttoptr_add_ptrtoint_used_by_single_icmp_operands_swapped(ptr %src, ptr %p2) {
4747
; CHECK-LABEL: @inttoptr_add_ptrtoint_used_by_single_icmp_operands_swapped(
48-
; CHECK-NEXT: [[I:%.*]] = ptrtoint ptr [[SRC:%.*]] to i64
49-
; CHECK-NEXT: [[A:%.*]] = add i64 [[I]], 10
50-
; CHECK-NEXT: [[P:%.*]] = inttoptr i64 [[A]] to ptr
51-
; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[P2:%.*]], [[P]]
48+
; CHECK-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[SRC:%.*]], i64 10
49+
; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[P2]], [[P:%.*]]
5250
; CHECK-NEXT: ret i1 [[C]]
5351
;
5452
%i = ptrtoint ptr %src to i64
@@ -60,10 +58,8 @@ define i1 @inttoptr_add_ptrtoint_used_by_single_icmp_operands_swapped(ptr %src,
6058

6159
define i1 @inttoptr_add_ptrtoint_used_by_single_icmp_constant_offset(ptr %src, i64 %off, ptr %p2) {
6260
; CHECK-LABEL: @inttoptr_add_ptrtoint_used_by_single_icmp_constant_offset(
63-
; CHECK-NEXT: [[I:%.*]] = ptrtoint ptr [[SRC:%.*]] to i64
64-
; CHECK-NEXT: [[A:%.*]] = add i64 [[OFF:%.*]], [[I]]
65-
; CHECK-NEXT: [[P:%.*]] = inttoptr i64 [[A]] to ptr
66-
; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[P2:%.*]], [[P]]
61+
; CHECK-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[SRC:%.*]], i64 [[OFF:%.*]]
62+
; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[P2]], [[P:%.*]]
6763
; CHECK-NEXT: ret i1 [[C]]
6864
;
6965
%i = ptrtoint ptr %src to i64
@@ -75,10 +71,8 @@ define i1 @inttoptr_add_ptrtoint_used_by_single_icmp_constant_offset(ptr %src, i
7571

7672
define i1 @inttoptr_add_ptrtoint_used_by_single_icmp_constant_offset_operands_swapped(ptr %src, i64 %off, ptr %p2) {
7773
; CHECK-LABEL: @inttoptr_add_ptrtoint_used_by_single_icmp_constant_offset_operands_swapped(
78-
; CHECK-NEXT: [[I:%.*]] = ptrtoint ptr [[SRC:%.*]] to i64
79-
; CHECK-NEXT: [[A:%.*]] = add i64 [[OFF:%.*]], [[I]]
80-
; CHECK-NEXT: [[P:%.*]] = inttoptr i64 [[A]] to ptr
81-
; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[P2:%.*]], [[P]]
74+
; CHECK-NEXT: [[P2:%.*]] = getelementptr i8, ptr [[SRC:%.*]], i64 [[OFF:%.*]]
75+
; CHECK-NEXT: [[C:%.*]] = icmp eq ptr [[P2]], [[P:%.*]]
8276
; CHECK-NEXT: ret i1 [[C]]
8377
;
8478
%i = ptrtoint ptr %src to i64

0 commit comments

Comments
 (0)