Skip to content

Commit 56c1d30

Browse files
authored
[IR] Remove support for lshr/ashr constant expressions (#71955)
Remove support for the lshr and ashr constant expressions. All places creating them have been removed beforehand, so this just removes the APIs and uses of these constant expressions in tests. This is part of https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179.
1 parent 9cb1673 commit 56c1d30

23 files changed

+54
-161
lines changed

llvm/bindings/ocaml/llvm/llvm.ml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,8 +654,6 @@ external const_icmp : Icmp.t -> llvalue -> llvalue -> llvalue
654654
external const_fcmp : Fcmp.t -> llvalue -> llvalue -> llvalue
655655
= "llvm_const_fcmp"
656656
external const_shl : llvalue -> llvalue -> llvalue = "llvm_const_shl"
657-
external const_lshr : llvalue -> llvalue -> llvalue = "llvm_const_lshr"
658-
external const_ashr : llvalue -> llvalue -> llvalue = "llvm_const_ashr"
659657
external const_gep : lltype -> llvalue -> llvalue array -> llvalue
660658
= "llvm_const_gep"
661659
external const_in_bounds_gep : lltype -> llvalue -> llvalue array -> llvalue

llvm/bindings/ocaml/llvm/llvm.mli

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,16 +1145,6 @@ val const_fcmp : Fcmp.t -> llvalue -> llvalue -> llvalue
11451145
See the method [llvm::ConstantExpr::getShl]. *)
11461146
val const_shl : llvalue -> llvalue -> llvalue
11471147

1148-
(** [const_lshr c1 c2] returns the constant integer [c1] right-shifted by the
1149-
constant integer [c2] with zero extension.
1150-
See the method [llvm::ConstantExpr::getLShr]. *)
1151-
val const_lshr : llvalue -> llvalue -> llvalue
1152-
1153-
(** [const_ashr c1 c2] returns the constant integer [c1] right-shifted by the
1154-
constant integer [c2] with sign extension.
1155-
See the method [llvm::ConstantExpr::getAShr]. *)
1156-
val const_ashr : llvalue -> llvalue -> llvalue
1157-
11581148
(** [const_gep srcty pc indices] returns the constant [getElementPtr] of [pc]
11591149
with source element type [srcty] and the constant integers indices from the
11601150
array [indices].

llvm/bindings/ocaml/llvm/llvm_ocaml.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,18 +1233,6 @@ value llvm_const_shl(value LHS, value RHS) {
12331233
return to_val(Value);
12341234
}
12351235

1236-
/* llvalue -> llvalue -> llvalue */
1237-
value llvm_const_lshr(value LHS, value RHS) {
1238-
LLVMValueRef Value = LLVMConstLShr(Value_val(LHS), Value_val(RHS));
1239-
return to_val(Value);
1240-
}
1241-
1242-
/* llvalue -> llvalue -> llvalue */
1243-
value llvm_const_ashr(value LHS, value RHS) {
1244-
LLVMValueRef Value = LLVMConstAShr(Value_val(LHS), Value_val(RHS));
1245-
return to_val(Value);
1246-
}
1247-
12481236
/* lltype -> llvalue -> llvalue array -> llvalue */
12491237
value llvm_const_gep(value Ty, value ConstantVal, value Indices) {
12501238
mlsize_t Length = Wosize_val(Indices);

llvm/docs/LangRef.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4693,10 +4693,6 @@ The following is the syntax for constant expressions:
46934693
Perform a multiplication on constants.
46944694
``shl (LHS, RHS)``
46954695
Perform a left shift on constants.
4696-
``lshr (LHS, RHS)``
4697-
Perform a logical right shift on constants.
4698-
``ashr (LHS, RHS)``
4699-
Perform an arithmetic right shift on constants.
47004696
``xor (LHS, RHS)``
47014697
Perform a bitwise xor on constants.
47024698

llvm/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ Changes to the LLVM IR
5757

5858
* ``and``
5959
* ``or``
60+
* ``lshr``
61+
* ``ashr``
6062
* ``zext``
6163
* ``sext``
6264
* ``fptrunc``
@@ -174,6 +176,8 @@ Changes to the C API
174176

175177
* ``LLVMConstAnd``
176178
* ``LLVMConstOr``
179+
* ``LLVMConstLShr``
180+
* ``LLVMConstAShr``
177181
* ``LLVMConstZExt``
178182
* ``LLVMConstSExt``
179183
* ``LLVMConstZExtOrBitCast``

llvm/include/llvm-c/Core.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2281,8 +2281,6 @@ LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate,
22812281
LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate,
22822282
LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
22832283
LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2284-
LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
2285-
LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant);
22862284
LLVMValueRef LLVMConstGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal,
22872285
LLVMValueRef *ConstantIndices, unsigned NumIndices);
22882286
LLVMValueRef LLVMConstInBoundsGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal,

llvm/include/llvm/IR/Constants.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,8 +1038,6 @@ class ConstantExpr : public Constant {
10381038
static Constant *getXor(Constant *C1, Constant *C2);
10391039
static Constant *getShl(Constant *C1, Constant *C2, bool HasNUW = false,
10401040
bool HasNSW = false);
1041-
static Constant *getLShr(Constant *C1, Constant *C2, bool isExact = false);
1042-
static Constant *getAShr(Constant *C1, Constant *C2, bool isExact = false);
10431041
static Constant *getTrunc(Constant *C, Type *Ty, bool OnlyIfReduced = false);
10441042
static Constant *getPtrToInt(Constant *C, Type *Ty,
10451043
bool OnlyIfReduced = false);
@@ -1085,14 +1083,6 @@ class ConstantExpr : public Constant {
10851083
return getShl(C1, C2, true, false);
10861084
}
10871085

1088-
static Constant *getExactAShr(Constant *C1, Constant *C2) {
1089-
return getAShr(C1, C2, true);
1090-
}
1091-
1092-
static Constant *getExactLShr(Constant *C1, Constant *C2) {
1093-
return getLShr(C1, C2, true);
1094-
}
1095-
10961086
/// If C is a scalar/fixed width vector of known powers of 2, then this
10971087
/// function returns a new scalar/fixed width vector obtained from logBase2
10981088
/// of C. Undef vector elements are set to zero.

llvm/lib/AsmParser/LLParser.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3852,6 +3852,10 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) {
38523852
return error(ID.Loc, "and constexprs are no longer supported");
38533853
case lltok::kw_or:
38543854
return error(ID.Loc, "or constexprs are no longer supported");
3855+
case lltok::kw_lshr:
3856+
return error(ID.Loc, "lshr constexprs are no longer supported");
3857+
case lltok::kw_ashr:
3858+
return error(ID.Loc, "ashr constexprs are no longer supported");
38553859
case lltok::kw_fneg:
38563860
return error(ID.Loc, "fneg constexprs are no longer supported");
38573861
case lltok::kw_select:
@@ -3910,12 +3914,9 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) {
39103914
case lltok::kw_sub:
39113915
case lltok::kw_mul:
39123916
case lltok::kw_shl:
3913-
case lltok::kw_lshr:
3914-
case lltok::kw_ashr:
39153917
case lltok::kw_xor: {
39163918
bool NUW = false;
39173919
bool NSW = false;
3918-
bool Exact = false;
39193920
unsigned Opc = Lex.getUIntVal();
39203921
Constant *Val0, *Val1;
39213922
Lex.Lex();
@@ -3928,10 +3929,6 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) {
39283929
if (EatIfPresent(lltok::kw_nuw))
39293930
NUW = true;
39303931
}
3931-
} else if (Opc == Instruction::SDiv || Opc == Instruction::UDiv ||
3932-
Opc == Instruction::LShr || Opc == Instruction::AShr) {
3933-
if (EatIfPresent(lltok::kw_exact))
3934-
Exact = true;
39353932
}
39363933
if (parseToken(lltok::lparen, "expected '(' in binary constantexpr") ||
39373934
parseGlobalTypeAndValue(Val0) ||
@@ -3948,7 +3945,6 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) {
39483945
unsigned Flags = 0;
39493946
if (NUW) Flags |= OverflowingBinaryOperator::NoUnsignedWrap;
39503947
if (NSW) Flags |= OverflowingBinaryOperator::NoSignedWrap;
3951-
if (Exact) Flags |= PossiblyExactOperator::IsExact;
39523948
ID.ConstantVal = ConstantExpr::get(Opc, Val0, Val1, Flags);
39533949
ID.Kind = ValID::t_Constant;
39543950
return false;

llvm/lib/IR/ConstantFold.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -155,29 +155,6 @@ static Constant *ExtractConstantBytes(Constant *C, unsigned ByteStart,
155155

156156
switch (CE->getOpcode()) {
157157
default: return nullptr;
158-
case Instruction::LShr: {
159-
ConstantInt *Amt = dyn_cast<ConstantInt>(CE->getOperand(1));
160-
if (!Amt)
161-
return nullptr;
162-
APInt ShAmt = Amt->getValue();
163-
// Cannot analyze non-byte shifts.
164-
if ((ShAmt & 7) != 0)
165-
return nullptr;
166-
ShAmt.lshrInPlace(3);
167-
168-
// If the extract is known to be all zeros, return zero.
169-
if (ShAmt.uge(CSize - ByteStart))
170-
return Constant::getNullValue(
171-
IntegerType::get(CE->getContext(), ByteSize * 8));
172-
// If the extract is known to be fully in the input, extract it.
173-
if (ShAmt.ule(CSize - (ByteStart + ByteSize)))
174-
return ExtractConstantBytes(CE->getOperand(0),
175-
ByteStart + ShAmt.getZExtValue(), ByteSize);
176-
177-
// TODO: Handle the 'partially zero' case.
178-
return nullptr;
179-
}
180-
181158
case Instruction::Shl: {
182159
ConstantInt *Amt = dyn_cast<ConstantInt>(CE->getOperand(1));
183160
if (!Amt)

llvm/lib/IR/Constants.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2160,13 +2160,13 @@ bool ConstantExpr::isSupportedBinOp(unsigned Opcode) {
21602160
case Instruction::FRem:
21612161
case Instruction::And:
21622162
case Instruction::Or:
2163+
case Instruction::LShr:
2164+
case Instruction::AShr:
21632165
return false;
21642166
case Instruction::Add:
21652167
case Instruction::Sub:
21662168
case Instruction::Mul:
21672169
case Instruction::Shl:
2168-
case Instruction::LShr:
2169-
case Instruction::AShr:
21702170
case Instruction::Xor:
21712171
return true;
21722172
default:
@@ -2482,16 +2482,6 @@ Constant *ConstantExpr::getShl(Constant *C1, Constant *C2,
24822482
return get(Instruction::Shl, C1, C2, Flags);
24832483
}
24842484

2485-
Constant *ConstantExpr::getLShr(Constant *C1, Constant *C2, bool isExact) {
2486-
return get(Instruction::LShr, C1, C2,
2487-
isExact ? PossiblyExactOperator::IsExact : 0);
2488-
}
2489-
2490-
Constant *ConstantExpr::getAShr(Constant *C1, Constant *C2, bool isExact) {
2491-
return get(Instruction::AShr, C1, C2,
2492-
isExact ? PossiblyExactOperator::IsExact : 0);
2493-
}
2494-
24952485
Constant *ConstantExpr::getExactLogBase2(Constant *C) {
24962486
Type *Ty = C->getType();
24972487
const APInt *IVal;

llvm/lib/IR/Core.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,16 +1712,6 @@ LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
17121712
unwrap<Constant>(RHSConstant)));
17131713
}
17141714

1715-
LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
1716-
return wrap(ConstantExpr::getLShr(unwrap<Constant>(LHSConstant),
1717-
unwrap<Constant>(RHSConstant)));
1718-
}
1719-
1720-
LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant) {
1721-
return wrap(ConstantExpr::getAShr(unwrap<Constant>(LHSConstant),
1722-
unwrap<Constant>(RHSConstant)));
1723-
}
1724-
17251715
LLVMValueRef LLVMConstGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal,
17261716
LLVMValueRef *ConstantIndices, unsigned NumIndices) {
17271717
ArrayRef<Constant *> IdxList(unwrap<Constant>(ConstantIndices, NumIndices),

llvm/test/Assembler/2003-05-21-MalformedShiftCrash.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
; RUN: not llvm-as < %s > /dev/null 2> %t
33
; RUN: grep "constexpr requires integer or integer vector operands" %t
44

5-
@0 = global i32 ashr (float 1.0, float 2.0)
5+
@0 = global i32 shl (float 1.0, float 2.0)

llvm/test/Assembler/2003-11-05-ConstantExprShift.ll

Lines changed: 0 additions & 6 deletions
This file was deleted.

llvm/test/Assembler/flags.ll

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -174,16 +174,6 @@ define i64 @mul_both_ce() {
174174
ret i64 mul nuw nsw (i64 ptrtoint (ptr @addr to i64), i64 91)
175175
}
176176

177-
define i64 @ashr_exact_ce() {
178-
; CHECK: ret i64 ashr exact (i64 ptrtoint (ptr @addr to i64), i64 9)
179-
ret i64 ashr exact (i64 ptrtoint (ptr @addr to i64), i64 9)
180-
}
181-
182-
define i64 @lshr_exact_ce() {
183-
; CHECK: ret i64 lshr exact (i64 ptrtoint (ptr @addr to i64), i64 9)
184-
ret i64 lshr exact (i64 ptrtoint (ptr @addr to i64), i64 9)
185-
}
186-
187177
define ptr @gep_nw_ce() {
188178
; CHECK: ret ptr getelementptr inbounds (i64, ptr @addr, i64 171)
189179
ret ptr getelementptr inbounds (i64, ptr @addr, i64 171)

llvm/test/Assembler/vector-shift.ll

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,3 @@ entry:
2424
%cmp = ashr <4 x i32> %a, %b ; <4 x i32> [#uses=1]
2525
ret <4 x i32> %cmp
2626
}
27-
28-
; Constant expressions: these should be folded.
29-
30-
; CHECK: @foo_ce
31-
; CHECK: ret <2 x i64> <i64 40, i64 192>
32-
define <2 x i64> @foo_ce() nounwind {
33-
ret <2 x i64> shl (<2 x i64> <i64 5, i64 6>, <2 x i64> <i64 3, i64 5>)
34-
}
35-
36-
; CHECK: @bar_ce
37-
; CHECK: ret <2 x i64> <i64 42, i64 11>
38-
define <2 x i64> @bar_ce() nounwind {
39-
ret <2 x i64> lshr (<2 x i64> <i64 340, i64 380>, <2 x i64> <i64 3, i64 5>)
40-
}
41-
42-
; CHECK: baz_ce
43-
; CHECK: ret <2 x i64> <i64 71, i64 12>
44-
define <2 x i64> @baz_ce() nounwind {
45-
ret <2 x i64> ashr (<2 x i64> <i64 573, i64 411>, <2 x i64> <i64 3, i64 5>)
46-
}

llvm/test/CodeGen/AArch64/fold-global-offsets.ll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ define i32 @f7() {
131131
; GISEL-NEXT: ret
132132

133133
entry:
134-
%l = load i32, ptr getelementptr (i32, ptr inttoptr (i64 trunc (i128 lshr (i128 bitcast (<2 x i64> <i64 undef, i64 ptrtoint (ptr getelementptr inbounds ({ [9 x ptr], [8 x ptr] }, ptr @x3, i64 0, inrange i32 1, i64 2) to i64)> to i128), i128 64) to i64) to ptr), i64 5)
134+
%lshr = lshr i128 bitcast (<2 x i64> <i64 undef, i64 ptrtoint (ptr getelementptr inbounds ({ [9 x ptr], [8 x ptr] }, ptr @x3, i64 0, inrange i32 1, i64 2) to i64)> to i128), 64
135+
%trunc = trunc i128 %lshr to i64
136+
%inttoptr = inttoptr i64 %trunc to ptr
137+
%gep = getelementptr i32, ptr %inttoptr, i64 5
138+
%l = load i32, ptr %gep
135139
ret i32 %l
136140
}

llvm/test/CodeGen/X86/2009-01-18-ConstantExprCrash.ll

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ bb4.i.i70: ; preds = %bb4.i.i70, %bb.i51
2525
br i1 false, label %_ZN11xercesc_2_59XMLString9stringLenEPKt.exit.i73, label %bb4.i.i70
2626

2727
_ZN11xercesc_2_59XMLString9stringLenEPKt.exit.i73: ; preds = %bb4.i.i70
28-
%0 = load i16, ptr getelementptr ([7 x i16], ptr @_ZN11xercesc_2_5L17gIdeographicCharsE, i32 0, i32 add (i32 ashr (i32 sub (i32 ptrtoint (ptr getelementptr ([7 x i16], ptr @_ZN11xercesc_2_5L17gIdeographicCharsE, i32 0, i32 4) to i32), i32 ptrtoint (ptr @_ZN11xercesc_2_5L17gIdeographicCharsE to i32)), i32 1), i32 1)), align 4 ; <i16> [#uses=0]
28+
%ashr = ashr i32 sub (i32 ptrtoint (ptr getelementptr ([7 x i16], ptr @_ZN11xercesc_2_5L17gIdeographicCharsE, i32 0, i32 4) to i32), i32 ptrtoint (ptr @_ZN11xercesc_2_5L17gIdeographicCharsE to i32)), 1
29+
%add = add i32 %ashr, 1
30+
%gep = getelementptr [7 x i16], ptr @_ZN11xercesc_2_5L17gIdeographicCharsE, i32 0, i32 %add
31+
%0 = load i16, ptr %gep, align 4
2932
br label %bb4.i5.i141
3033

3134
bb4.i5.i141: ; preds = %bb4.i5.i141, %_ZN11xercesc_2_59XMLString9stringLenEPKt.exit.i73

llvm/test/CodeGen/X86/pre-coalesce-2.ll

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ if.end5: ; preds = %while.body
8686
br i1 %cmp6, label %if.end14, label %cleanup.thread40
8787

8888
if.end14: ; preds = %if.end5
89-
%22 = load i8, ptr inttoptr (i64 add (i64 lshr (i64 ptrtoint (ptr @a to i64), i64 3), i64 2147450880) to ptr)
89+
%lshr1 = lshr i64 ptrtoint (ptr @a to i64), 3
90+
%add1 = add i64 %lshr1, 2147450880
91+
%inttoptr1 = inttoptr i64 %add1 to ptr
92+
%22 = load i8, ptr %inttoptr1
9093
%23 = icmp ne i8 %22, 0
9194
br i1 %23, label %24, label %25
9295

@@ -177,7 +180,10 @@ cleanup.thread40: ; preds = %if.end5
177180
br label %enoent
178181

179182
cleanup: ; preds = %while.body
180-
%61 = load i8, ptr inttoptr (i64 add (i64 lshr (i64 ptrtoint (ptr @b to i64), i64 3), i64 2147450880) to ptr)
183+
%lshr2 = lshr i64 ptrtoint (ptr @b to i64), 3
184+
%add2 = add i64 %lshr2, 2147450880
185+
%inttoptr2 = inttoptr i64 %add2 to ptr
186+
%61 = load i8, ptr %inttoptr2
181187
%62 = icmp ne i8 %61, 0
182188
br i1 %62, label %63, label %66
183189

llvm/test/DebugInfo/AArch64/asan-stack-vars.mir

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@
133133
store i8* %_cmd, i8** %_cmd.addr, align 8
134134
call void @llvm.dbg.declare(metadata i8** %_cmd.addr, metadata !48, metadata !DIExpression()), !dbg !47
135135
%29 = load %struct._class_t*, %struct._class_t** @"OBJC_CLASSLIST_REFERENCES_$_", align 8, !dbg !50
136-
%30 = add i64 lshr (i64 ptrtoint (i8** @OBJC_SELECTOR_REFERENCES_ to i64), i64 3), %1, !dbg !50
136+
%lshr1 = lshr i64 ptrtoint (i8** @OBJC_SELECTOR_REFERENCES_ to i64), 3, !dbg !50
137+
%30 = add i64 %lshr1, %1, !dbg !50
137138
%31 = inttoptr i64 %30 to i8*, !dbg !50
138139
%32 = load i8, i8* %31, !dbg !50
139140
%33 = icmp ne i8 %32, 0, !dbg !50
@@ -149,7 +150,8 @@
149150
%37 = bitcast %struct._class_t* %29 to i8*, !dbg !50
150151
%call = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(i8* %37, i8* %36), !dbg !50
151152
%38 = bitcast i8* %call to %0*, !dbg !50
152-
%39 = add i64 lshr (i64 ptrtoint (i8** @OBJC_SELECTOR_REFERENCES_.2 to i64), i64 3), %1, !dbg !51
153+
%lshr2 = lshr i64 ptrtoint (i8** @OBJC_SELECTOR_REFERENCES_.2 to i64), 3, !dbg !51
154+
%39 = add i64 %lshr2, %1, !dbg !51
153155
%40 = inttoptr i64 %39 to i8*, !dbg !51
154156
%41 = load i8, i8* %40, !dbg !51
155157
%42 = icmp ne i8 %41, 0, !dbg !51
@@ -197,7 +199,8 @@
197199
; <label>:65: ; preds = %55
198200
store %0* %57, %0** %6, align 8, !dbg !44
199201
%66 = load %0*, %0** %6, align 8, !dbg !52
200-
%67 = add i64 lshr (i64 ptrtoint (i8** @OBJC_SELECTOR_REFERENCES_.4 to i64), i64 3), %1, !dbg !53
202+
%lshr3 = lshr i64 ptrtoint (i8** @OBJC_SELECTOR_REFERENCES_.4 to i64), 3, !dbg !53
203+
%67 = add i64 %lshr3, %1, !dbg !53
201204
%68 = inttoptr i64 %67 to i8*, !dbg !53
202205
%69 = load i8, i8* %68, !dbg !53
203206
%70 = icmp ne i8 %69, 0, !dbg !53

llvm/test/Transforms/InstCombine/and-or.ll

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,13 @@ define <2 x i8> @and_or_hoist_mask_commute_vec_splat(<2 x i8> %a, <2 x i8> %b) {
322322

323323
define i32 @pr64114_and_xor_hoist_mask_constexpr() {
324324
; CHECK-LABEL: @pr64114_and_xor_hoist_mask_constexpr(
325-
; CHECK-NEXT: [[AND:%.*]] = and i32 xor (i32 lshr (i32 ptrtoint (ptr @g to i32), i32 8), i32 ptrtoint (ptr @g to i32)), 1
325+
; CHECK-NEXT: [[LSHR:%.*]] = lshr i32 ptrtoint (ptr @g to i32), 8
326+
; CHECK-NEXT: [[AND:%.*]] = and i32 [[LSHR]], 1
326327
; CHECK-NEXT: ret i32 [[AND]]
327328
;
328-
%and = and i32 xor (i32 lshr (i32 ptrtoint (ptr @g to i32), i32 8), i32 ptrtoint (ptr @g to i32)), 1
329+
%lshr = lshr i32 ptrtoint (ptr @g to i32), 8
330+
%xor = xor i32 %lshr, ptrtoint (ptr @g to i32)
331+
%and = and i32 %xor, 1
329332
ret i32 %and
330333
}
331334

0 commit comments

Comments
 (0)