Skip to content

DAG: Preserve range metadata when load is narrowed #128144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 26, 2025

Conversation

LU-JOHN
Copy link
Contributor

@LU-JOHN LU-JOHN commented Feb 21, 2025

In DAGCombiner.cpp preserve range metadata when load is narrowed to load LSBs if original range metadata bounds can fit in the narrower type.

Utilize preserved range metadata to reduce 64-bit shl to 32-bit shl.

@llvmbot llvmbot added backend:AMDGPU llvm:SelectionDAG SelectionDAGISel as well labels Feb 21, 2025
@llvmbot
Copy link
Member

llvmbot commented Feb 21, 2025

@llvm/pr-subscribers-llvm-selectiondag

@llvm/pr-subscribers-backend-amdgpu

Author: None (LU-JOHN)

Changes

In DAGCombiner.cpp preserve range metadata when load is narrowed to load LSBs if original range metadata bounds can fit in the narrower type.

Utilize preserved range metadata to reduce 64-bit shl to 32-bit shl.


Full diff: https://github.com/llvm/llvm-project/pull/128144.diff

2 Files Affected:

  • (modified) llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (+33-6)
  • (modified) llvm/test/CodeGen/AMDGPU/shl64_reduce.ll (+34-4)
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index bc7cdf38dbc2a..ba59bf269ba86 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -14903,12 +14903,39 @@ SDValue DAGCombiner::reduceLoadWidth(SDNode *N) {
   AddToWorklist(NewPtr.getNode());
 
   SDValue Load;
-  if (ExtType == ISD::NON_EXTLOAD)
-    Load = DAG.getLoad(VT, DL, LN0->getChain(), NewPtr,
-                       LN0->getPointerInfo().getWithOffset(PtrOff),
-                       LN0->getOriginalAlign(),
-                       LN0->getMemOperand()->getFlags(), LN0->getAAInfo());
-  else
+  if (ExtType == ISD::NON_EXTLOAD) {
+    const MDNode *OldRanges = LN0->getRanges();
+    const MDNode *NewRanges = nullptr;
+    /* If LSBs are loaded and all bounds in the OldRanges metadata fit in
+       the narrower size, preserve the range information by translating
+       to the the new narrower type, NewTy */
+    if (ShAmt == 0 && OldRanges) {
+      Type *NewTy = VT.getTypeForEVT(*DAG.getContext());
+      const unsigned NumOperands = OldRanges->getNumOperands();
+      const unsigned NewWidth = NewTy->getIntegerBitWidth();
+      bool InRange = true;
+      SmallVector<Metadata *, 4> Bounds;
+      Bounds.reserve(NumOperands);
+
+      for (unsigned i = 0; i < NumOperands; ++i) {
+        const APInt &BoundValue =
+            mdconst::extract<ConstantInt>(OldRanges->getOperand(i))->getValue();
+        if (BoundValue.getBitWidth() - BoundValue.getNumSignBits() >=
+            NewWidth) {
+          InRange = false;
+          break;
+        }
+        Bounds.push_back(ConstantAsMetadata::get(
+            ConstantInt::get(NewTy, BoundValue.trunc(NewWidth))));
+      }
+      if (InRange)
+        NewRanges = MDNode::get(*DAG.getContext(), Bounds);
+    }
+    Load = DAG.getLoad(
+        VT, DL, LN0->getChain(), NewPtr,
+        LN0->getPointerInfo().getWithOffset(PtrOff), LN0->getOriginalAlign(),
+        LN0->getMemOperand()->getFlags(), LN0->getAAInfo(), NewRanges);
+  } else
     Load = DAG.getExtLoad(ExtType, DL, VT, LN0->getChain(), NewPtr,
                           LN0->getPointerInfo().getWithOffset(PtrOff), ExtVT,
                           LN0->getOriginalAlign(),
diff --git a/llvm/test/CodeGen/AMDGPU/shl64_reduce.ll b/llvm/test/CodeGen/AMDGPU/shl64_reduce.ll
index 05430213c17d2..55bfc079cb1c4 100644
--- a/llvm/test/CodeGen/AMDGPU/shl64_reduce.ll
+++ b/llvm/test/CodeGen/AMDGPU/shl64_reduce.ll
@@ -21,11 +21,39 @@ define i64 @shl_metadata(i64 %arg0, ptr %arg1.ptr) {
 ; CHECK-LABEL: shl_metadata:
 ; CHECK:       ; %bb.0:
 ; CHECK-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; CHECK-NEXT:    flat_load_dword v1, v[2:3]
+; CHECK-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
+; CHECK-NEXT:    v_lshlrev_b32_e32 v1, v1, v0
+; CHECK-NEXT:    v_mov_b32_e32 v0, 0
+; CHECK-NEXT:    s_setpc_b64 s[30:31]
+  %shift.amt = load i64, ptr %arg1.ptr, !range !0, !noundef !{}
+  %shl = shl i64 %arg0, %shift.amt
+  ret i64 %shl
+}
+
+define i64 @shl_metadata_two_ranges(i64 %arg0, ptr %arg1.ptr) {
+; CHECK-LABEL: shl_metadata_two_ranges:
+; CHECK:       ; %bb.0:
+; CHECK-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
+; CHECK-NEXT:    flat_load_dword v1, v[2:3]
+; CHECK-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
+; CHECK-NEXT:    v_lshlrev_b32_e32 v1, v1, v0
+; CHECK-NEXT:    v_mov_b32_e32 v0, 0
+; CHECK-NEXT:    s_setpc_b64 s[30:31]
+  %shift.amt = load i64, ptr %arg1.ptr, !range !1, !noundef !{}
+  %shl = shl i64 %arg0, %shift.amt
+  ret i64 %shl
+}
+
+define i64 @shl_metadata_out_of_range(i64 %arg0, ptr %arg1.ptr) {
+; CHECK-LABEL: shl_metadata_out_of_range:
+; CHECK:       ; %bb.0:
+; CHECK-NEXT:    s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
 ; CHECK-NEXT:    flat_load_dword v2, v[2:3]
 ; CHECK-NEXT:    s_waitcnt vmcnt(0) lgkmcnt(0)
 ; CHECK-NEXT:    v_lshlrev_b64 v[0:1], v2, v[0:1]
 ; CHECK-NEXT:    s_setpc_b64 s[30:31]
-  %shift.amt = load i64, ptr %arg1.ptr, !range !0
+  %shift.amt = load i64, ptr %arg1.ptr, !range !2, !noundef !{}
   %shl = shl i64 %arg0, %shift.amt
   ret i64 %shl
 }
@@ -39,7 +67,7 @@ define <2 x i64> @shl_v2_metadata(<2 x i64> %arg0, ptr %arg1.ptr) {
 ; CHECK-NEXT:    v_lshlrev_b64 v[0:1], v4, v[0:1]
 ; CHECK-NEXT:    v_lshlrev_b64 v[2:3], v6, v[2:3]
 ; CHECK-NEXT:    s_setpc_b64 s[30:31]
-  %shift.amt = load <2 x i64>, ptr %arg1.ptr, !range !0
+  %shift.amt = load <2 x i64>, ptr %arg1.ptr, !range !0, !noundef !{}
   %shl = shl <2 x i64> %arg0, %shift.amt
   ret <2 x i64> %shl
 }
@@ -55,7 +83,7 @@ define <3 x i64> @shl_v3_metadata(<3 x i64> %arg0, ptr %arg1.ptr) {
 ; CHECK-NEXT:    v_lshlrev_b64 v[0:1], v8, v[0:1]
 ; CHECK-NEXT:    v_lshlrev_b64 v[2:3], v10, v[2:3]
 ; CHECK-NEXT:    s_setpc_b64 s[30:31]
-  %shift.amt = load <3 x i64>, ptr %arg1.ptr, !range !0
+  %shift.amt = load <3 x i64>, ptr %arg1.ptr, !range !0, !noundef !{}
   %shl = shl <3 x i64> %arg0, %shift.amt
   ret <3 x i64> %shl
 }
@@ -74,12 +102,14 @@ define <4 x i64> @shl_v4_metadata(<4 x i64> %arg0, ptr %arg1.ptr) {
 ; CHECK-NEXT:    v_lshlrev_b64 v[4:5], v13, v[4:5]
 ; CHECK-NEXT:    v_lshlrev_b64 v[6:7], v15, v[6:7]
 ; CHECK-NEXT:    s_setpc_b64 s[30:31]
-  %shift.amt = load <4 x i64>, ptr %arg1.ptr, !range !0
+  %shift.amt = load <4 x i64>, ptr %arg1.ptr, !range !0, !noundef !{}
   %shl = shl <4 x i64> %arg0, %shift.amt
   ret <4 x i64> %shl
 }
 
 !0 = !{i64 32, i64 64}
+!1 = !{i64 32, i64 38, i64 42, i64 48}
+!2 = !{i64 31, i64 38, i64 42, i64 48}
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ; Test range with an "or X, 16"

if (ExtType == ISD::NON_EXTLOAD) {
const MDNode *OldRanges = LN0->getRanges();
const MDNode *NewRanges = nullptr;
/* If LSBs are loaded and all bounds in the OldRanges metadata fit in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The core logic ideally would go in a utility function on ConstantRanges, not directly inline here. We will eventually want to share the same logic with globalisel

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used ConstantRange::getMinSignedBits() to implement core logic.

const MDNode *OldRanges = LN0->getRanges();
const MDNode *NewRanges = nullptr;
/* If LSBs are loaded and all bounds in the OldRanges metadata fit in
the narrower size, preserve the range information by translating
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need new negative tests if it's not in range?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added negative test where bounds cannot fit in 32-bits.

Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just get the ConstantRange and trunc() it? I really don't think trying to preserve the sub-ranges is worthwhile.

@LU-JOHN
Copy link
Contributor Author

LU-JOHN commented Feb 22, 2025

Can we just get the ConstantRange and trunc() it? I really don't think trying to preserve the sub-ranges is worthwhile.

Make one new range to cover all previous sub-ranges.

@LU-JOHN LU-JOHN requested review from nikic and arsenm February 24, 2025 16:35
Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to me.

't use getTypeForEVT, remove const

Signed-off-by: John Lu <[email protected]>
@arsenm arsenm changed the title Preserve range metadata when load is narrowed DAG: Preserve range metadata when load is narrowed Feb 26, 2025
@arsenm arsenm merged commit d8bcb53 into llvm:main Feb 26, 2025
11 checks passed
@thurstond
Copy link
Contributor

The ASan builds have been failing, and I think it may be related to this DAGCombiner change (first seen in https://lab.llvm.org/buildbot/#/builders/52/builds/6343). Could you please take a look?

CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build0/bin/clang++ -DCLANG_EXPORTS -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/tools/clang/lib/StaticAnalyzer/Core -I/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/StaticAnalyzer/Core -I/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/include -I/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/tools/clang/include -I/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/include -I/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include -nostdinc++ -isystem /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_install_asan/include -isystem /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_install_asan/include/c++/v1 -fsanitize=address -Wl,--rpath=/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_install_asan/lib -L/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_install_asan/lib -w -stdlib=libc++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fno-omit-frame-pointer -gline-tables-only -fsanitize=address -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/RangeConstraintManager.cpp.o -MF tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/RangeConstraintManager.cpp.o.d -o tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/RangeConstraintManager.cpp.o -c /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
clang++: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/IR/ConstantRange.cpp:875: ConstantRange llvm::ConstantRange::truncate(uint32_t) const: Assertion `getBitWidth() > DstTySize && "Not a value truncation"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build0/bin/clang++ -fsanitize=address -L/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_install_asan/lib -w -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fno-omit-frame-pointer -gline-tables-only -fsanitize=address -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 -std=c++17 -fno-exceptions -funwind-tables -fno-rtti -fdiagnostics-color -Wl,--rpath=/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_install_asan/lib -DCLANG_EXPORTS -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/tools/clang/lib/StaticAnalyzer/Core -I/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/StaticAnalyzer/Core -I/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/include -I/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/tools/clang/include -I/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/include -I/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include -nostdinc++ -isystem /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_install_asan/include -isystem /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_install_asan/include/c++/v1 -stdlib=libc++ -DNDEBUG -UNDEBUG -c -MD -MT tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/RangeConstraintManager.cpp.o -MF tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/RangeConstraintManager.cpp.o.d -fcolor-diagnostics -o tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/RangeConstraintManager.cpp.o /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module '/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp'.
4.	Running pass 'X86 DAG->DAG Instruction Selection' on function '@_ZN12_GLOBAL__N_121SymbolicRangeInferrer19VisitBinaryOperatorEN5clang4ento8RangeSetENS1_18BinaryOperatorKindES3_NS1_8QualTypeE'
 #0 0x000060a5218b70b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build0/bin/clang+++0x84dc0b8)
 #1 0x000060a5218b4b6e llvm::sys::RunSignalHandlers() (/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build0/bin/clang+++0x84d9b6e)
 #2 0x000060a52181e336 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x0000745fbde45250 (/lib/x86_64-linux-gnu/libc.so.6+0x45250)
 #4 0x0000745fbdea3f1c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0xa3f1c)
 #5 0x0000745fbde4519e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4519e)
 #6 0x0000745fbde28902 abort (/lib/x86_64-linux-gnu/libc.so.6+0x28902)
 #7 0x0000745fbde2881e (/lib/x86_64-linux-gnu/libc.so.6+0x2881e)
 #8 0x0000745fbde3b7c7 (/lib/x86_64-linux-gnu/libc.so.6+0x3b7c7)
 #9 0x000060a52116eb71 llvm::ConstantRange::truncate(unsigned int) const (/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build0/bin/clang+++0x7d93b71)
#10 0x000060a522abaec4 (anonymous namespace)::DAGCombiner::reduceLoadWidth(llvm::SDNode*) DAGCombiner.cpp:0:0
#11 0x000060a522a6f7d0 (anonymous namespace)::DAGCombiner::visitTRUNCATE(llvm::SDNode*) DAGCombiner.cpp:0:0
#12 0x000060a522a47516 (anonymous namespace)::DAGCombiner::combine(llvm::SDNode*) DAGCombiner.cpp:0:0
#13 0x000060a522a452f6 llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::BatchAAResults*, llvm::CodeGenOptLevel) (/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build0/bin/clang+++0x966a2f6)
#14 0x000060a522c0b349 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build0/bin/clang+++0x9830349)

The ASan builds were red prior to this change but due to other patches (with different failure reports).

@dyung
Copy link
Collaborator

dyung commented Feb 26, 2025

We are also seeing the same assertion failure in some of our internal testing which I bisected back to this commit. I am currently working on trying to get a smaller repro.

@mysterymath
Copy link
Contributor

This has been causing a build failure on the Fuchsia toolchain clang build. I've verified that reverting this PR allows clang to once again build successfully, so I'm issuing a revert.

[1526/5272](61) Building CXX object lib/Transforms/Vectorize/CMakeFiles/LLVMVectorize.dir/LoopVectorize.cpp.o
FAILED: lib/Transforms/Vectorize/CMakeFiles/LLVMVectorize.dir/LoopVectorize.cpp.o 
/b/s/w/ir/x/w/llvm_build/./bin/clang++ --sysroot=/b/s/w/ir/x/w/cipd/linux -DGTEST_HAS_RTTI=0 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/b/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/lib/Transforms/Vectorize -I/b/s/w/ir/x/w/llvm-llvm-project/llvm/lib/Transforms/Vectorize -I/b/s/w/ir/x/w/cipd/model/tensorflow/include -I/b/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/include -I/b/s/w/ir/x/w/llvm-llvm-project/llvm/include -isystem /b/s/w/ir/x/w/zlib_install_target/include -isystem /b/s/w/ir/x/w/zstd_install/include -stdlib=libc++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -flto=full -ffat-lto-objects -ffile-prefix-map=/b/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins=../../../../llvm-llvm-project -ffile-prefix-map=/b/s/w/ir/x/w/llvm-llvm-project/= -no-canonical-prefixes -O3 -DNDEBUG -std=c++17 -fvisibility=default  -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -MD -MT lib/Transforms/Vectorize/CMakeFiles/LLVMVectorize.dir/LoopVectorize.cpp.o -MF lib/Transforms/Vectorize/CMakeFiles/LLVMVectorize.dir/LoopVectorize.cpp.o.d -o lib/Transforms/Vectorize/CMakeFiles/LLVMVectorize.dir/LoopVectorize.cpp.o -c /b/s/w/ir/x/w/llvm-llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
clang++: llvm/lib/IR/ConstantRange.cpp:875: ConstantRange llvm::ConstantRange::truncate(uint32_t) const: Assertion `getBitWidth() > DstTySize && "Not a value truncation"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /b/s/w/ir/x/w/llvm_build/./bin/clang++ --sysroot=/b/s/w/ir/x/w/cipd/linux -DGTEST_HAS_RTTI=0 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/b/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/lib/Transforms/Vectorize -I/b/s/w/ir/x/w/llvm-llvm-project/llvm/lib/Transforms/Vectorize -I/b/s/w/ir/x/w/cipd/model/tensorflow/include -I/b/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins/include -I/b/s/w/ir/x/w/llvm-llvm-project/llvm/include -isystem /b/s/w/ir/x/w/zlib_install_target/include -isystem /b/s/w/ir/x/w/zstd_install/include -stdlib=libc++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -flto=full -ffat-lto-objects -ffile-prefix-map=/b/s/w/ir/x/w/llvm_build/tools/clang/stage2-bins=../../../../llvm-llvm-project -ffile-prefix-map=/b/s/w/ir/x/w/llvm-llvm-project/= -no-canonical-prefixes -O3 -DNDEBUG -std=c++17 -fvisibility=default -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -MD -MT lib/Transforms/Vectorize/CMakeFiles/LLVMVectorize.dir/LoopVectorize.cpp.o -MF lib/Transforms/Vectorize/CMakeFiles/LLVMVectorize.dir/LoopVectorize.cpp.o.d -o lib/Transforms/Vectorize/CMakeFiles/LLVMVectorize.dir/LoopVectorize.cpp.o -c /b/s/w/ir/x/w/llvm-llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module '/b/s/w/ir/x/w/llvm-llvm-project/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp'.
4.	Running pass 'X86 DAG->DAG Instruction Selection' on function '@_ZN4llvm17VPReplicateRecipe7executeERNS_16VPTransformStateE'
#0 0x000055ef1dc8fcd8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/b/s/w/ir/x/w/llvm_build/./bin/clang+++0x442fcd8)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Fuchsia clang version 21.0.0git (https://llvm.googlesource.com/llvm-project 900220d444257633cc7d1be1475d4da1be58e0ed)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /b/s/w/ir/x/w/llvm_build/./bin
Build config: +assertions
clang++: note: diagnostic msg: 
********************

mysterymath added a commit that referenced this pull request Feb 26, 2025
mysterymath added a commit that referenced this pull request Feb 26, 2025
Reverts #128144

Breaks clang prod x64 build (seen in Fuchsia toolchain)
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Feb 26, 2025
…" (#128948)

Reverts llvm/llvm-project#128144

Breaks clang prod x64 build (seen in Fuchsia toolchain)
LU-JOHN added a commit to LU-JOHN/llvm-project that referenced this pull request Mar 10, 2025
)

Changes: Add guard to ensure truncation is strictly smaller than original size.
LU-JOHN added a commit to LU-JOHN/llvm-project that referenced this pull request Mar 11, 2025
)

Changes: Add guard to ensure truncation is strictly smaller than original size.
arsenm pushed a commit that referenced this pull request Mar 13, 2025
…#130609)

Changes: Add guard to ensure truncation is strictly smaller than
original size.

---------

Signed-off-by: John Lu <[email protected]>
frederik-h pushed a commit to frederik-h/llvm-project that referenced this pull request Mar 18, 2025
) (llvm#130609)

Changes: Add guard to ensure truncation is strictly smaller than
original size.

---------

Signed-off-by: John Lu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:AMDGPU llvm:SelectionDAG SelectionDAGISel as well
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants