[llvm] [SimplifyCFG] Truncate integers in switch lookup tables (PR #120893)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 22 04:33:58 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: DaPorkchop_ (DaMatrix)
<details>
<summary>Changes</summary>
Real-world switches often return integer values in a much smaller range than the actual range of the integer type being returned. This change enables us to detect when all integer values in a switch lookup table only differ from each other in a smaller subset of the possible bit positions, truncate the lookup table elements to a narrower width and extend them at runtime.
This has two main benefits:
- Reduces the memory footprint of lookup tables without additional runtime overhead (most architectures have zero-extending widening load instructions), resulting in smaller executable sizes and less cache pollution
- Makes a many more lookup tables small enough to fit into a bitmap, eliminating the need for any loads
---
Patch is 49.78 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/120893.diff
11 Files Affected:
- (modified) llvm/lib/Transforms/Utils/SimplifyCFG.cpp (+160)
- (modified) llvm/test/Transforms/SimplifyCFG/ARM/switch-to-lookup-table.ll (+1-1)
- (modified) llvm/test/Transforms/SimplifyCFG/Hexagon/switch-to-lookup-table.ll (+3-2)
- (modified) llvm/test/Transforms/SimplifyCFG/RISCV/switch-of-powers-of-two.ll (+5-2)
- (modified) llvm/test/Transforms/SimplifyCFG/X86/switch-covered-bug.ll (+5-3)
- (modified) llvm/test/Transforms/SimplifyCFG/X86/switch-table-bug.ll (+2-3)
- (modified) llvm/test/Transforms/SimplifyCFG/X86/switch-to-lookup-large-types.ll (+8-6)
- (modified) llvm/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll (+143-43)
- (modified) llvm/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table_big.ll (+35-28)
- (modified) llvm/test/Transforms/SimplifyCFG/switch-dead-default-lookup-table.ll (+5-2)
- (modified) llvm/test/Transforms/SimplifyCFG/switch_mask.ll (+5-2)
``````````diff
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 17f4b396f753b4..7e6c87d4a6bb1c 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -196,6 +196,8 @@ static cl::opt<unsigned> MaxSwitchCasesPerResult(
STATISTIC(NumBitMaps, "Number of switch instructions turned into bitmaps");
STATISTIC(NumLinearMaps,
"Number of switch instructions turned into linear mapping");
+STATISTIC(NumTruncatedInts, "Number of switch instructions turned into lookup "
+ "tables with a truncated value");
STATISTIC(NumLookupTables,
"Number of switch instructions turned into lookup tables");
STATISTIC(
@@ -6486,6 +6488,13 @@ class SwitchLookupTable {
// shift and mask operations.
BitMapKind,
+ // For tables with integer elements which only differ in a small subset
+ // of their bits, we can truncate the values to a smaller type to discard
+ // the bits which are the same for all values, saving memory. Values are
+ // retrieved by retrieving the truncated value from a lookup table, then
+ // extending and OR-ing to re-construct the original values.
+ TruncatedIntKind,
+
// The table is stored as an array of values. Values are retrieved by load
// instructions from the table.
ArrayKind
@@ -6503,6 +6512,14 @@ class SwitchLookupTable {
ConstantInt *LinearMultiplier = nullptr;
bool LinearMapValWrapped = false;
+ // For TruncatedIntKind, these are the truncated lookup table and the
+ // constants used to reconstruct original values from their truncated forms.
+ std::unique_ptr<SwitchLookupTable> TruncatedLookupTable = nullptr;
+ IntegerType *TruncatedOrigTy = nullptr;
+ ConstantInt *TruncatedShift = nullptr;
+ ConstantInt *TruncatedMask = nullptr;
+ bool TruncatedValWrapped = false;
+
// For ArrayKind, this is the array.
GlobalVariable *Array = nullptr;
};
@@ -6622,6 +6639,132 @@ SwitchLookupTable::SwitchLookupTable(
return;
}
+ // Check if we can truncate the value to a smaller form by discarding leading
+ // and trailing bits which are the same for all values.
+ if (isa<IntegerType>(ValueType)) {
+ IntegerType *IT = cast<IntegerType>(ValueType);
+ unsigned OrigWidth = IT->getBitWidth();
+
+ // Figure out which bits are always the same.
+ APInt AlwaysOneBits = APInt::getAllOnes(OrigWidth);
+ APInt AlwaysZeroBits = APInt::getAllOnes(OrigWidth);
+ for (Constant *TableEntry : TableContents) {
+ // Each entry in the lookup table may be a constant integer, otherwise
+ // it must be undefined (Undef or poison) in which case we can simply
+ // skip it.
+ if (isa<ConstantInt>(TableEntry)) {
+ const APInt &Val = cast<ConstantInt>(TableEntry)->getValue();
+ AlwaysOneBits &= Val;
+ AlwaysZeroBits &= ~Val;
+ }
+ }
+ assert((AlwaysOneBits & AlwaysZeroBits).isZero() &&
+ "A bit cannot be both zero and one in every case");
+ APInt NotChangingBits = AlwaysOneBits | AlwaysZeroBits;
+
+ unsigned DiscardedHighBits = NotChangingBits.countLeadingOnes();
+ unsigned DiscardedLowBits = NotChangingBits.countTrailingOnes();
+ unsigned TotalDiscardedBits = DiscardedHighBits + DiscardedLowBits;
+ unsigned TruncatedWidth = OrigWidth - TotalDiscardedBits;
+
+ // If the original type's width is a power of two, we want to ensure
+ // that the truncated size is also a power of two. Otherwise, the higher
+ // cost of indexing into the array with non-power-of-two-sized elements is
+ // probably going to cancel out any benefits we might get from making the
+ // table smaller.
+ if (has_single_bit(OrigWidth)) {
+ unsigned OldTruncatedWidth = TruncatedWidth;
+ TruncatedWidth = bit_ceil(TruncatedWidth);
+
+ // If the truncated size increased, we need to decrease DiscardedHighBits
+ // and/or DiscardedLowBits accordingly.
+ unsigned TruncatedWidthIncrease = TruncatedWidth - OldTruncatedWidth;
+ if (TruncatedWidthIncrease) {
+ TotalDiscardedBits -= TruncatedWidthIncrease;
+
+ // Prioritize decreasing the number of least significant bits discarded:
+ // if we can get this to 0, we won't need to shift left
+ unsigned LowBitsDecrease =
+ std::min(TruncatedWidthIncrease, DiscardedLowBits);
+ DiscardedLowBits -= LowBitsDecrease;
+
+ unsigned HighBitsDecrease = std::min(
+ TruncatedWidthIncrease - LowBitsDecrease, DiscardedHighBits);
+ DiscardedHighBits -= HighBitsDecrease;
+
+ assert(TruncatedWidthIncrease == LowBitsDecrease + HighBitsDecrease);
+
+ assert(DiscardedHighBits + DiscardedLowBits == TotalDiscardedBits &&
+ TotalDiscardedBits + TruncatedWidth == OrigWidth);
+ }
+ }
+
+ // We'll only truncate the values if the truncated values would be less than
+ // half the size of the original values, as otherwise there's unlikely to be
+ // any benefit.
+ if (TruncatedWidth <= OrigWidth / 2) {
+ IntegerType *TruncatedTy =
+ IntegerType::get(M.getContext(), TruncatedWidth);
+
+ PoisonValue *TruncatedPoison = PoisonValue::get(TruncatedTy);
+
+ // Truncate the values and build a new lookup table containing them
+ SmallVector<std::pair<ConstantInt *, Constant *>, 64> TruncatedValues(
+ TableSize);
+ for (uint64_t I = 0; I < TableSize; ++I) {
+ ConstantInt *CaseVal =
+ ConstantInt::get(M.getContext(), Offset->getValue() + I);
+ Constant *CaseRes = TableContents[I];
+
+ Constant *TruncatedCaseRes;
+ if (ConstantInt *IntCaseRes = dyn_cast<ConstantInt>(CaseRes)) {
+ APInt TruncatedVal = IntCaseRes->getValue().extractBits(
+ TruncatedWidth, DiscardedLowBits);
+ TruncatedCaseRes = ConstantInt::get(M.getContext(), TruncatedVal);
+ } else if (isa<PoisonValue>(CaseRes)) {
+ TruncatedCaseRes = TruncatedPoison;
+ } else {
+ assert(isa<UndefValue>(CaseRes));
+ // To avoid making a call to the deprecated
+ // 'UndefValue ::get(TruncatedTy)', we'll simply replace undefined
+ // table entries with zero.
+ TruncatedCaseRes =
+ ConstantInt::get(M.getContext(), APInt::getZero(TruncatedWidth));
+ }
+
+ assert(TruncatedCaseRes->getType() == TruncatedTy);
+
+ TruncatedValues[I] = {CaseVal, TruncatedCaseRes};
+ }
+
+ // Recursively construct a new lookup table with the truncated values.
+ // This enables us to use more efficient table kinds which weren't
+ // possible originally, such as a bitmap.
+ TruncatedLookupTable = std::make_unique<SwitchLookupTable>(
+ M, TableSize, Offset, TruncatedValues, TruncatedPoison, DL,
+ ("switch.truncated." + FuncName).str());
+ TruncatedOrigTy = IT;
+
+ if (DiscardedLowBits > 0) {
+ TruncatedShift = ConstantInt::get(IT, DiscardedLowBits);
+ TruncatedValWrapped = DiscardedHighBits == 0;
+ }
+
+ // The mask we OR on at the end consists of all the bits which are always
+ // one, excluding the bits which fit into the truncated value and didn't
+ // need to be changed.
+ APInt Mask =
+ AlwaysOneBits & ~APInt::getBitsSet(OrigWidth, DiscardedLowBits,
+ OrigWidth - DiscardedHighBits);
+ if (!Mask.isZero())
+ TruncatedMask = ConstantInt::get(M.getContext(), Mask);
+
+ Kind = TruncatedIntKind;
+ ++NumTruncatedInts;
+ return;
+ }
+ }
+
// Store the table in an array.
ArrayType *ArrayTy = ArrayType::get(ValueType, TableSize);
Constant *Initializer = ConstantArray::get(ArrayTy, TableContents);
@@ -6677,6 +6820,23 @@ Value *SwitchLookupTable::buildLookup(Value *Index, IRBuilder<> &Builder) {
// Mask off.
return Builder.CreateTrunc(DownShifted, BitMapElementTy, "switch.masked");
}
+ case TruncatedIntKind: {
+ // Load the truncated value from the lookup table
+ Value *TruncatedVal = TruncatedLookupTable->buildLookup(Index, Builder);
+
+ // Derive the original value from the truncated version
+ Value *Result = Builder.CreateIntCast(TruncatedVal, TruncatedOrigTy, false,
+ "switch.truncatedint.cast");
+ if (TruncatedShift)
+ Result =
+ Builder.CreateShl(Result, TruncatedShift, "switch.truncatedint.shift",
+ /*HasNUW =*/true,
+ /*HasNSW =*/!TruncatedValWrapped);
+ if (TruncatedMask)
+ Result =
+ Builder.CreateOr(Result, TruncatedMask, "switch.truncatedint.mask");
+ return Result;
+ }
case ArrayKind: {
// Make sure the table index will not overflow when treated as signed.
IntegerType *IT = cast<IntegerType>(Index->getType());
diff --git a/llvm/test/Transforms/SimplifyCFG/ARM/switch-to-lookup-table.ll b/llvm/test/Transforms/SimplifyCFG/ARM/switch-to-lookup-table.ll
index 6def8f4eeb0891..8a910f30601112 100644
--- a/llvm/test/Transforms/SimplifyCFG/ARM/switch-to-lookup-table.ll
+++ b/llvm/test/Transforms/SimplifyCFG/ARM/switch-to-lookup-table.ll
@@ -10,7 +10,7 @@
; RUN: opt -S -passes='simplifycfg<switch-to-lookup>' -mtriple=arm -relocation-model=rwpi < %s | FileCheck %s --check-prefix=CHECK --check-prefix=DISABLE
; RUN: opt -S -passes='simplifycfg<switch-to-lookup>' -mtriple=arm -relocation-model=ropi-rwpi < %s | FileCheck %s --check-prefix=CHECK --check-prefix=DISABLE
-; CHECK: @{{.*}} = private unnamed_addr constant [3 x i32] [i32 1234, i32 5678, i32 15532]
+; CHECK: @{{.*}} = private unnamed_addr constant [3 x i16] [i16 1234, i16 5678, i16 15532]
; ENABLE: @{{.*}} = private unnamed_addr constant [3 x ptr] [ptr @c1, ptr @c2, ptr @c3]
; DISABLE-NOT: @{{.*}} = private unnamed_addr constant [3 x ptr] [ptr @c1, ptr @c2, ptr @c3]
; ENABLE: @{{.*}} = private unnamed_addr constant [3 x ptr] [ptr @g1, ptr @g2, ptr @g3]
diff --git a/llvm/test/Transforms/SimplifyCFG/Hexagon/switch-to-lookup-table.ll b/llvm/test/Transforms/SimplifyCFG/Hexagon/switch-to-lookup-table.ll
index 349a18148460f4..9975c051d71270 100644
--- a/llvm/test/Transforms/SimplifyCFG/Hexagon/switch-to-lookup-table.ll
+++ b/llvm/test/Transforms/SimplifyCFG/Hexagon/switch-to-lookup-table.ll
@@ -13,8 +13,9 @@ define i32 @foo(i32 %x) #0 section ".tcm_text" {
; ENABLE-NEXT: [[TMP0:%.*]] = icmp ult i32 [[X:%.*]], 6
; ENABLE-NEXT: br i1 [[TMP0]], label [[SWITCH_LOOKUP:%.*]], label [[RETURN:%.*]]
; ENABLE: switch.lookup:
-; ENABLE-NEXT: [[SWITCH_GEP:%.*]] = getelementptr inbounds nuw [6 x i32], ptr @switch.table.foo, i32 0, i32 [[X]]
-; ENABLE-NEXT: [[SWITCH_LOAD:%.*]] = load i32, ptr [[SWITCH_GEP]], align 4
+; ENABLE-NEXT: [[SWITCH_GEP:%.*]] = getelementptr inbounds nuw [6 x i8], ptr @switch.table.switch.truncated.foo, i32 0, i32 [[X]]
+; ENABLE-NEXT: [[SWITCH_LOAD1:%.*]] = load i8, ptr [[SWITCH_GEP]], align 1
+; ENABLE-NEXT: [[SWITCH_LOAD:%.*]] = zext i8 [[SWITCH_LOAD1]] to i32
; ENABLE-NEXT: br label [[RETURN]]
; ENABLE: return:
; ENABLE-NEXT: [[RETVAL_0:%.*]] = phi i32 [ [[SWITCH_LOAD]], [[SWITCH_LOOKUP]] ], [ 19, [[ENTRY:%.*]] ]
diff --git a/llvm/test/Transforms/SimplifyCFG/RISCV/switch-of-powers-of-two.ll b/llvm/test/Transforms/SimplifyCFG/RISCV/switch-of-powers-of-two.ll
index 2ac94afd959105..f1a51bdfe331a8 100644
--- a/llvm/test/Transforms/SimplifyCFG/RISCV/switch-of-powers-of-two.ll
+++ b/llvm/test/Transforms/SimplifyCFG/RISCV/switch-of-powers-of-two.ll
@@ -34,8 +34,11 @@ define i32 @switch_of_powers(i32 %x) {
; RV64ZBB-LABEL: @switch_of_powers(
; RV64ZBB-NEXT: entry:
; RV64ZBB-NEXT: [[TMP0:%.*]] = call i32 @llvm.cttz.i32(i32 [[X:%.*]], i1 true)
-; RV64ZBB-NEXT: [[SWITCH_GEP:%.*]] = getelementptr inbounds [7 x i32], ptr @switch.table.switch_of_powers, i32 0, i32 [[TMP0]]
-; RV64ZBB-NEXT: [[SWITCH_LOAD:%.*]] = load i32, ptr [[SWITCH_GEP]], align 4
+; RV64ZBB-NEXT: [[SWITCH_CAST:%.*]] = zext i32 [[TMP0]] to i56
+; RV64ZBB-NEXT: [[SWITCH_SHIFTAMT:%.*]] = mul nuw nsw i56 [[SWITCH_CAST]], 8
+; RV64ZBB-NEXT: [[SWITCH_DOWNSHIFT:%.*]] = lshr i56 11821953350566659, [[SWITCH_SHIFTAMT]]
+; RV64ZBB-NEXT: [[SWITCH_MASKED:%.*]] = trunc i56 [[SWITCH_DOWNSHIFT]] to i8
+; RV64ZBB-NEXT: [[SWITCH_LOAD:%.*]] = zext i8 [[SWITCH_MASKED]] to i32
; RV64ZBB-NEXT: ret i32 [[SWITCH_LOAD]]
;
entry:
diff --git a/llvm/test/Transforms/SimplifyCFG/X86/switch-covered-bug.ll b/llvm/test/Transforms/SimplifyCFG/X86/switch-covered-bug.ll
index cf244e6b63457c..df1425798a219e 100644
--- a/llvm/test/Transforms/SimplifyCFG/X86/switch-covered-bug.ll
+++ b/llvm/test/Transforms/SimplifyCFG/X86/switch-covered-bug.ll
@@ -10,9 +10,11 @@ define i64 @test(i3 %arg) {
; CHECK-LABEL: @test(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[SWITCH_TABLEIDX:%.*]] = sub i3 [[ARG:%.*]], -4
-; CHECK-NEXT: [[SWITCH_TABLEIDX_ZEXT:%.*]] = zext i3 [[SWITCH_TABLEIDX]] to i4
-; CHECK-NEXT: [[SWITCH_GEP:%.*]] = getelementptr inbounds [8 x i64], ptr @switch.table.test, i32 0, i4 [[SWITCH_TABLEIDX_ZEXT]]
-; CHECK-NEXT: [[SWITCH_LOAD:%.*]] = load i64, ptr [[SWITCH_GEP]], align 8
+; CHECK-NEXT: [[SWITCH_CAST:%.*]] = zext i3 [[SWITCH_TABLEIDX]] to i32
+; CHECK-NEXT: [[SWITCH_SHIFTAMT:%.*]] = mul nuw nsw i32 [[SWITCH_CAST]], 4
+; CHECK-NEXT: [[SWITCH_DOWNSHIFT:%.*]] = lshr i32 -638023754, [[SWITCH_SHIFTAMT]]
+; CHECK-NEXT: [[SWITCH_MASKED:%.*]] = trunc i32 [[SWITCH_DOWNSHIFT]] to i4
+; CHECK-NEXT: [[SWITCH_LOAD:%.*]] = zext i4 [[SWITCH_MASKED]] to i64
; CHECK-NEXT: [[V3:%.*]] = add i64 [[SWITCH_LOAD]], 0
; CHECK-NEXT: ret i64 [[V3]]
;
diff --git a/llvm/test/Transforms/SimplifyCFG/X86/switch-table-bug.ll b/llvm/test/Transforms/SimplifyCFG/X86/switch-table-bug.ll
index 37001f4fba2aa8..d32ad9b9351bec 100644
--- a/llvm/test/Transforms/SimplifyCFG/X86/switch-table-bug.ll
+++ b/llvm/test/Transforms/SimplifyCFG/X86/switch-table-bug.ll
@@ -10,9 +10,8 @@ define i64 @_TFO6reduce1E5toRawfS0_FT_Si(i2) {
; CHECK-LABEL: @_TFO6reduce1E5toRawfS0_FT_Si(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[SWITCH_TABLEIDX:%.*]] = sub i2 [[TMP0:%.*]], -2
-; CHECK-NEXT: [[SWITCH_TABLEIDX_ZEXT:%.*]] = zext i2 [[SWITCH_TABLEIDX]] to i3
-; CHECK-NEXT: [[SWITCH_GEP:%.*]] = getelementptr inbounds [4 x i64], ptr @switch.table._TFO6reduce1E5toRawfS0_FT_Si, i32 0, i3 [[SWITCH_TABLEIDX_ZEXT]]
-; CHECK-NEXT: [[SWITCH_LOAD:%.*]] = load i64, ptr [[SWITCH_GEP]], align 8
+; CHECK-NEXT: [[SWITCH_OFFSET:%.*]] = add i2 [[SWITCH_TABLEIDX]], -2
+; CHECK-NEXT: [[SWITCH_LOAD:%.*]] = zext i2 [[SWITCH_OFFSET]] to i64
; CHECK-NEXT: ret i64 [[SWITCH_LOAD]]
;
entry:
diff --git a/llvm/test/Transforms/SimplifyCFG/X86/switch-to-lookup-large-types.ll b/llvm/test/Transforms/SimplifyCFG/X86/switch-to-lookup-large-types.ll
index e188cd8057df2d..b5220844986801 100644
--- a/llvm/test/Transforms/SimplifyCFG/X86/switch-to-lookup-large-types.ll
+++ b/llvm/test/Transforms/SimplifyCFG/X86/switch-to-lookup-large-types.ll
@@ -5,8 +5,8 @@
target triple = "x86_64-unknown-linux-gnu"
;.
-; CHECK: @switch.table.switch_to_lookup_i64 = private unnamed_addr constant [3 x i8] c"\03\01\02", align 1
-; CHECK: @switch.table.switch_to_lookup_i128 = private unnamed_addr constant [3 x i8] c"\03\01\02", align 1
+; CHECK: @switch.table.switch.truncated.switch_to_lookup_i64 = private unnamed_addr constant [3 x i2] [i2 -1, i2 1, i2 -2], align 1
+; CHECK: @switch.table.switch.truncated.switch_to_lookup_i128 = private unnamed_addr constant [3 x i2] [i2 -1, i2 1, i2 -2], align 1
;.
define i8 @switch_to_lookup_i64(i64 %x){
; CHECK-LABEL: @switch_to_lookup_i64(
@@ -17,8 +17,9 @@ define i8 @switch_to_lookup_i64(i64 %x){
; CHECK-NEXT: [[COMMON_RET_OP:%.*]] = phi i8 [ [[SWITCH_LOAD:%.*]], [[SWITCH_LOOKUP]] ], [ 10, [[START:%.*]] ]
; CHECK-NEXT: ret i8 [[COMMON_RET_OP]]
; CHECK: switch.lookup:
-; CHECK-NEXT: [[SWITCH_GEP:%.*]] = getelementptr inbounds [3 x i8], ptr @switch.table.switch_to_lookup_i64, i32 0, i64 [[X]]
-; CHECK-NEXT: [[SWITCH_LOAD]] = load i8, ptr [[SWITCH_GEP]], align 1
+; CHECK-NEXT: [[SWITCH_GEP:%.*]] = getelementptr inbounds [3 x i2], ptr @switch.table.switch.truncated.switch_to_lookup_i64, i32 0, i64 [[X]]
+; CHECK-NEXT: [[SWITCH_LOAD1:%.*]] = load i2, ptr [[SWITCH_GEP]], align 1
+; CHECK-NEXT: [[SWITCH_LOAD]] = zext i2 [[SWITCH_LOAD1]] to i8
; CHECK-NEXT: br label [[COMMON_RET]]
;
; INLINE-LABEL: @switch_to_lookup_i64(
@@ -61,8 +62,9 @@ define i8 @switch_to_lookup_i128(i128 %x){
; CHECK-NEXT: [[COMMON_RET_OP:%.*]] = phi i8 [ [[SWITCH_LOAD:%.*]], [[SWITCH_LOOKUP]] ], [ 10, [[START:%.*]] ]
; CHECK-NEXT: ret i8 [[COMMON_RET_OP]]
; CHECK: switch.lookup:
-; CHECK-NEXT: [[SWITCH_GEP:%.*]] = getelementptr inbounds [3 x i8], ptr @switch.table.switch_to_lookup_i128, i32 0, i128 [[X]]
-; CHECK-NEXT: [[SWITCH_LOAD]] = load i8, ptr [[SWITCH_GEP]], align 1
+; CHECK-NEXT: [[SWITCH_GEP:%.*]] = getelementptr inbounds [3 x i2], ptr @switch.table.switch.truncated.switch_to_lookup_i128, i32 0, i128 [[X]]
+; CHECK-NEXT: [[SWITCH_LOAD1:%.*]] = load i2, ptr [[SWITCH_GEP]], align 1
+; CHECK-NEXT: [[SWITCH_LOAD]] = zext i2 [[SWITCH_LOAD1]] to i8
; CHECK-NEXT: br label [[COMMON_RET]]
;
; INLINE-LABEL: @switch_to_lookup_i128(
diff --git a/llvm/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll b/llvm/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll
index 7f484e2ec29d7d..ceeb16561dbc6c 100644
--- a/llvm/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll
+++ b/llvm/test/Transforms/SimplifyCFG/X86/switch_to_lookup_table.ll
@@ -27,18 +27,11 @@ target triple = "x86_64-unknown-linux-gnu"
; CHECK: @switch.table.char = private unnamed_addr constant [9 x i8] c"7{\00\FF\1B>\01!T", align 1
; CHECK: @switch.table.h = private unnamed_addr constant [4 x float] [float 0x40091EB860000000, float 0x3FF3BE76C0000000, float 0x4012449BA0000000, float 0x4001AE1480000000], align 4
; CHECK: @switch.table.foostring = private unnamed_addr constant [4 x ptr] [ptr @.str, ptr @.str1, ptr @.str2, ptr @.str3], align 8
-; CHECK: @switch.table.earlyreturncrash = private unnamed_addr constant [4 x i32] [i32 42, i32 9, i32 88, i32 5], align 4
-; CHECK: @switch.table.earlyreturncrash.1 = private unnamed_addr constant [4 x i32] [i32 3, i32 4, i32 1, i32 5], align 4
-; CHECK: @switch.table.large = private unnamed_addr constant [199 x i32] [i32 1, i32 4, i32 9, i32 16, i32 25, i32 36, i32 49, i32 64, i32 81, i32 100, i32 121, i32 144, i32 169, i32 196, i32 225, i32 256, i32 289, i32 342, i32 361, i32 400, i32 441, i32 484, i32 529, i32 576, i32 625, i32 676, i32 729, i32 784, i32 841, i32 900, i32 961, i32 1024, i32 1089, i32 1156, i32 1260, i32 1296, i32 1369, i32 1444, i32 1521, i32 1600, i32 1681, i32 1764, i32 1849, i32 1980, i32 2025, i32 2116, i32 2209, i32 2304, i32 2401, i32 2500, i32 2601, i32 2704, i32 2809, i32 2970, i32 3025, i32 3136, i32 3249, i32 3364, i32 3481, i32 3600, i32 3721, i32 3844, i32 3969, i32 4096, i32 4225, i32 4356, i32 4489, i32 4624, i32 4761, i32 4900, i32 5112, i32 5184, i32 5329, i32 5476, i32 5625, i32 5776, i32 5929, i32 6084, i32 6241, i32 6400, i32 6561, i32 6724, i32 6889, i32 7056, i32 7225, i32 7396, i32 7569, i32 7744, i32 7921, i32 8100, i32 8281, i32 8464, i32 8649, i32 8836, i32 9025, i32 9216, i32 9409, i32 9604, i32 9801, i32 10000, i32 10201, i32 10404, i32 10609, i32 10816, i32 11025, i32 11236, i32 11449, i32 11664, i32 11881, i32 12100, i32 12321, i32 12544, i32 12769, i32 12996, i32 13225, i32 13456, i32 13689, i32 13924, i32 14161, i32 14400, i32 14641, i32 14884, i32 15129, i32 15376, i32 15625, i32 15876, i32 16129, i32 16384, i32 16641, i32 16900, i32 17161, i32 17424, i32 17689, i32 17956, i32 18225, i32 18496, i32 18769, i32 19044, i32 19321, i32 19600, i32 19881, i32 20164, i32 20449, i32 20736, i32 21025, i32 21316, i32 21609, i32 21904, i32 22201, i32 22500, i32 22801, i32 23104, i32 23409, i32 23716, i32 24025, i32 24336, i32 24649, i32 24964, i32 25281, i32 25600, i32 25921, i32 26244, i32 26569, i32 26896, i32 27225, i32 27556, i32 27889, i32 28224, i32 28561, i32 28900, i32 29241, i32 29584, i32 29929, i32 30276, i32 30625, i32 30976, i32 31329, i32 31684, i32 32041, i32 32400, i32 32761, i32 33124, i32 33489, i32 33856, i32 34225, i32 34596, i32 3496...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/120893
More information about the llvm-commits
mailing list