Skip to content
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

[instCombine][bugfix] Fix crash caused by using of cast in instCombineSVECmpNE #102472

Merged
merged 1 commit into from
Aug 23, 2024

Conversation

cceerczw
Copy link
Contributor

@cceerczw cceerczw commented Aug 8, 2024

Func instCombineSVECmpNE is used to identify specific pattern of instruction 'svecmene',
and then predict its result, use the result to replace instruction 'svecmene'. The specific pattern can be descriped below:
1.The svecmpne must compare all elements of vec.
2.The svecmpne inst compare its ves with zero.
3.The vec in svecmpne inst is generated by inst dupqlane, and the copy value of this dupqlane must be zero.
In NO.3 above, func instCombineSVECmpNE uses 'cast' to transform op1 of dupqlane without checking if the cast is success, then generate a crash in some situation.

@llvmbot
Copy link
Member

llvmbot commented Aug 8, 2024

@llvm/pr-subscribers-llvm-transforms

@llvm/pr-subscribers-backend-aarch64

Author: None (cceerczw)

Changes

…eSVECmpNE.

Func instCombineSVECmpNE is used to identify specific pattern of instruction 'svecmene',
and then predict its result, use the result to replace instruction 'svecmene'. The specific pattern can be descriped below:
1.The svecmpne must compare all elements of vec.
2.The svecmpne inst compare its ves with zero.
3.The vec in svecmpne inst is generated by inst dupqlane, and the copy value of this dupqlane must be zero.
In NO.3 above, func instCombineSVECmpNE uses 'cast' to transform op1 of dupqlane without checking if the cast is success, then generate a crash in some situation.


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

2 Files Affected:

  • (modified) llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp (+2-1)
  • (added) llvm/test/Transforms/InstCombine/AArch64/sve-inst-combine-cmpne.ll (+58)
diff --git a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
index 79c0e45e3aa5b5..c27c56d4557b14 100644
--- a/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
+++ b/llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
@@ -1174,7 +1174,8 @@ static std::optional<Instruction *> instCombineSVECmpNE(InstCombiner &IC,
     return std::nullopt;
 
   // Where the dupq is a lane 0 replicate of a vector insert
-  if (!cast<ConstantInt>(DupQLane->getArgOperand(1))->isZero())
+  auto *DupQLaneOp1 = dyn_cast<ConstantInt>(DupQLane->getArgOperand(1));
+  if (!DupQLaneOp1 || !DupQLaneOp1->isZero())
     return std::nullopt;
 
   auto *VecIns = dyn_cast<IntrinsicInst>(DupQLane->getArgOperand(0));
diff --git a/llvm/test/Transforms/InstCombine/AArch64/sve-inst-combine-cmpne.ll b/llvm/test/Transforms/InstCombine/AArch64/sve-inst-combine-cmpne.ll
new file mode 100644
index 00000000000000..b21f2f538d3cab
--- /dev/null
+++ b/llvm/test/Transforms/InstCombine/AArch64/sve-inst-combine-cmpne.ll
@@ -0,0 +1,58 @@
+; RUN: opt -S -mtriple=aarch64-unknown-linux-gnu -O2 < %s | FileCheck %s
+ 
+; Function Attrs: nofree nosync nounwind readnone uwtable vscale_range(1,16)
+define dso_local i32 @testInstCombineSVECmpNE() local_unnamed_addr #0 {
+entry:
+  %0 = tail call <vscale x 16 x i8> @llvm.aarch64.sve.index.nxv16i8(i8 42, i8 1)
+  %1 = tail call <vscale x 16 x i1> @llvm.aarch64.sve.ptrue.nxv16i1(i32 31)
+  br label %for.body
+ 
+for.cond.cleanup:                                 ; preds = %for.inc
+  %2 = tail call i1 @llvm.aarch64.sve.ptest.any.nxv16i1(<vscale x 16 x i1> %1, <vscale x 16 x i1> %cmp_rslt.1)
+  %not. = xor i1 %2, true
+  %. = zext i1 %not. to i32
+  ret i32 %.
+ 
+for.body:                                         ; preds = %entry, %for.inc
+  %i.010 = phi i64 [ 0, %entry ], [ %inc, %for.inc ]
+  %cmp1 = icmp ugt i64 %i.010, 32
+  %3 = tail call <vscale x 16 x i8> @llvm.aarch64.sve.dupq.lane.nxv16i8(<vscale x 16 x i8> %0, i64 %i.010)
+  br i1 %cmp1, label %if.then, label %if.else
+ 
+if.then:                                          ; preds = %for.body
+  %4 = tail call <vscale x 16 x i1> @llvm.aarch64.sve.cmpne.nxv16i8(<vscale x 16 x i1> %1, <vscale x 16 x i8> %3, <vscale x 16 x i8> zeroinitializer)
+  br label %for.inc
+  ; CHECK: %4 = tail call <vscale x 16 x i1> @llvm.aarch64.sve.cmpne.nxv16i8(<vscale x 16 x i1> %1, <vscale x 16 x i8> %3, <vscale x 16 x i8> zeroinitializer)
+  ; CHECK-NEXT: br label %for.inc
+ 
+if.else:                                          ; preds = %for.body
+  %5 = tail call <vscale x 16 x i1> @llvm.aarch64.sve.cmpne.nxv16i8(<vscale x 16 x i1> %1, <vscale x 16 x i8> %3, <vscale x 16 x i8> shufflevector (<vscale x 16 x i8> insertelement (<vscale x 16 x i8> poison, i8 1, i32 0), <vscale x 16 x i8> poison, <vscale x 16 x i32> zeroinitializer))
+  br label %for.inc
+ 
+for.inc:                                          ; preds = %if.then, %if.else
+  %cmp_rslt.1 = phi <vscale x 16 x i1> [ %4, %if.then ], [ %5, %if.else ]
+  %inc = add nuw nsw i64 %i.010, 1
+  %exitcond.not = icmp eq i64 %inc, 63
+  br i1 %exitcond.not, label %for.cond.cleanup, label %for.body, !llvm.loop !6
+}
+ 
+; Function Attrs: mustprogress nocallback nofree nosync nounwind readnone willreturn
+declare <vscale x 16 x i8> @llvm.aarch64.sve.index.nxv16i8(i8, i8) #1
+ 
+; Function Attrs: mustprogress nocallback nofree nosync nounwind readnone willreturn
+declare <vscale x 16 x i1> @llvm.aarch64.sve.ptrue.nxv16i1(i32 immarg) #1
+ 
+; Function Attrs: mustprogress nocallback nofree nosync nounwind readnone willreturn
+declare <vscale x 16 x i8> @llvm.aarch64.sve.dupq.lane.nxv16i8(<vscale x 16 x i8>, i64) #1
+ 
+; Function Attrs: mustprogress nocallback nofree nosync nounwind readnone willreturn
+declare <vscale x 16 x i1> @llvm.aarch64.sve.cmpne.nxv16i8(<vscale x 16 x i1>, <vscale x 16 x i8>, <vscale x 16 x i8>) #1
+ 
+; Function Attrs: mustprogress nocallback nofree nosync nounwind readnone willreturn
+declare i1 @llvm.aarch64.sve.ptest.any.nxv16i1(<vscale x 16 x i1>, <vscale x 16 x i1>) #1
+ 
+attributes #0 = { nofree nosync nounwind readnone uwtable vscale_range(1,16) "frame-pointer"="non-leaf" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon,+sve,+v8.2a" }
+attributes #1 = { mustprogress nocallback nofree nosync nounwind readnone willreturn }
+ 
+!6 = distinct !{!6, !7}
+!7 = !{!"llvm.loop.mustprogress"}

@dtcxzyw dtcxzyw changed the title [instCombine][bugfix] Fix crash caused by using of cast in instCombin… [instCombine][bugfix] Fix crash caused by using of cast in instCombineSVECmpNE Aug 8, 2024
@dtcxzyw dtcxzyw requested a review from paulwalker-arm August 8, 2024 14:20
Copy link
Collaborator

@paulwalker-arm paulwalker-arm left a comment

Choose a reason for hiding this comment

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

Fix looks good but the test case can be significantly reduced. It looks like you can just add to llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-opts-cmpne.ll by cloning dupq_b_0 as dupq_b_idx whereby it takes an %idx function parameter that it uses when calling sve.dupq.lane.

@@ -1174,7 +1174,8 @@ static std::optional<Instruction *> instCombineSVECmpNE(InstCombiner &IC,
return std::nullopt;

// Where the dupq is a lane 0 replicate of a vector insert
if (!cast<ConstantInt>(DupQLane->getArgOperand(1))->isZero())
auto *DupQLaneOp1 = dyn_cast<ConstantInt>(DupQLane->getArgOperand(1));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Up to you but I think DupQLaneIdx would be more readable.

Choose a reason for hiding this comment

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

Ok, fixed.

@wuxie2022
Copy link

Fix looks good but the test case can be significantly reduced. It looks like you can just add to llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-opts-cmpne.ll by cloning dupq_b_0 as dupq_b_idx whereby it takes an %idx function parameter that it uses when calling sve.dupq.lane.

Thank you for your review! I have simplified the case in 'sve-inst-combine-cmpne.ll'. But it can't be merged into sve-intrinsic-opts-cmpne.ll, because the compile command of my new test case must contain '-mtriple=aarch64-unknown-linux-gnu' and '-O2'.

@cceerczw cceerczw force-pushed the fix-instcombine-crash branch from 0b7ff03 to 3771bbf Compare August 15, 2024 03:44
@paulwalker-arm
Copy link
Collaborator

Fix looks good but the test case can be significantly reduced. It looks like you can just add to llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-opts-cmpne.ll by cloning dupq_b_0 as dupq_b_idx whereby it takes an %idx function parameter that it uses when calling sve.dupq.lane.

Thank you for your review! I have simplified the case in 'sve-inst-combine-cmpne.ll'. But it can't be merged into sve-intrinsic-opts-cmpne.ll, because the compile command of my new test case must contain '-mtriple=aarch64-unknown-linux-gnu' and '-O2'.

Are you sure? sve-intrinsic-opts-cmpne.ll already contains a target triple line and I think the only reason you need -O2 is because you're relying on function inlining? I've just tried my suggestion on the current main branch and adding the following to sve-intrinsic-opts-cmpne.ll triggers the original failure for me. Do you not see the same?

define <vscale x 16 x i1> @dupq_b_idx(i64 %idx) #0 {                                
  %1 = tail call <vscale x 16 x i1> @llvm.aarch64.sve.ptrue.nxv16i1(i32 31)         
  %2 = tail call <vscale x 16 x i8> @llvm.vector.insert.nxv16i8.v16i8(<vscale x 16 x i8> undef,
    <16 x i8> <i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0,                      
               i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0>, i64 0)              
  %3 = tail call <vscale x 16 x i8> @llvm.aarch64.sve.dupq.lane.nxv16i8(<vscale x 16 x i8> %2 , i64 %idx)
  %4 = tail call <vscale x 2 x i64> @llvm.aarch64.sve.dup.x.nxv2i64(i64 0)          
  %5 = tail call <vscale x 16 x i1> @llvm.aarch64.sve.cmpne.wide.nxv16i8(<vscale x 16 x i1> %1, <vscale x 16 x i8> %3, <vscale x 2 x i64> %4)
  ret <vscale x 16 x i1> %5                                                         
} 

@wuxie2022
Copy link

wuxie2022 commented Aug 16, 2024

Fix looks good but the test case can be significantly reduced. It looks like you can just add to llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-opts-cmpne.ll by cloning dupq_b_0 as dupq_b_idx whereby it takes an %idx function parameter that it uses when calling sve.dupq.lane.

Thank you for your review! I have simplified the case in 'sve-inst-combine-cmpne.ll'. But it can't be merged into sve-intrinsic-opts-cmpne.ll, because the compile command of my new test case must contain '-mtriple=aarch64-unknown-linux-gnu' and '-O2'.

Are you sure? sve-intrinsic-opts-cmpne.ll already contains a target triple line and I think the only reason you need -O2 is because you're relying on function inlining? I've just tried my suggestion on the current main branch and adding the following to sve-intrinsic-opts-cmpne.ll triggers the original failure for me. Do you not see the same?

define <vscale x 16 x i1> @dupq_b_idx(i64 %idx) #0 {                                
  %1 = tail call <vscale x 16 x i1> @llvm.aarch64.sve.ptrue.nxv16i1(i32 31)         
  %2 = tail call <vscale x 16 x i8> @llvm.vector.insert.nxv16i8.v16i8(<vscale x 16 x i8> undef,
    <16 x i8> <i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0,                      
               i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0>, i64 0)              
  %3 = tail call <vscale x 16 x i8> @llvm.aarch64.sve.dupq.lane.nxv16i8(<vscale x 16 x i8> %2 , i64 %idx)
  %4 = tail call <vscale x 2 x i64> @llvm.aarch64.sve.dup.x.nxv2i64(i64 0)          
  %5 = tail call <vscale x 16 x i1> @llvm.aarch64.sve.cmpne.wide.nxv16i8(<vscale x 16 x i1> %1, <vscale x 16 x i8> %3, <vscale x 2 x i64> %4)
  ret <vscale x 16 x i1> %5                                                         
} 

Fix looks good but the test case can be significantly reduced. It looks like you can just add to llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-opts-cmpne.ll by cloning dupq_b_0 as dupq_b_idx whereby it takes an %idx function parameter that it uses when calling sve.dupq.lane.

Thank you for your review! I have simplified the case in 'sve-inst-combine-cmpne.ll'. But it can't be merged into sve-intrinsic-opts-cmpne.ll, because the compile command of my new test case must contain '-mtriple=aarch64-unknown-linux-gnu' and '-O2'.

Are you sure? sve-intrinsic-opts-cmpne.ll already contains a target triple line and I think the only reason you need -O2 is because you're relying on function inlining? I've just tried my suggestion on the current main branch and adding the following to sve-intrinsic-opts-cmpne.ll triggers the original failure for me. Do you not see the same?

define <vscale x 16 x i1> @dupq_b_idx(i64 %idx) #0 {                                
  %1 = tail call <vscale x 16 x i1> @llvm.aarch64.sve.ptrue.nxv16i1(i32 31)         
  %2 = tail call <vscale x 16 x i8> @llvm.vector.insert.nxv16i8.v16i8(<vscale x 16 x i8> undef,
    <16 x i8> <i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0,                      
               i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0>, i64 0)              
  %3 = tail call <vscale x 16 x i8> @llvm.aarch64.sve.dupq.lane.nxv16i8(<vscale x 16 x i8> %2 , i64 %idx)
  %4 = tail call <vscale x 2 x i64> @llvm.aarch64.sve.dup.x.nxv2i64(i64 0)          
  %5 = tail call <vscale x 16 x i1> @llvm.aarch64.sve.cmpne.wide.nxv16i8(<vscale x 16 x i1> %1, <vscale x 16 x i8> %3, <vscale x 2 x i64> %4)
  ret <vscale x 16 x i1> %5                                                         
} 

When I try your suggestion, the compiler didn't generate any failure. I have also test in https://www.godbolt.org/ using 'opt(trunk)'. Besides, the original failure which I want to fix is like:

`PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-trunk/bin/opt -o /app/output.s -S -mtriple=aarch64-unknown-linux-gnu -O2

  1. Running pass "function(mem2reg,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>)" on module ""
  2. Running pass "instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>" on function "testInstCombineSVECmpNE"
    #0 0x0000000004be7748 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/opt+0x4be7748)
    Fixing Rust build #1 0x0000000004be50ec SignalHandler(int) Signals.cpp:0:0
    Fix a typo #2 0x00007fe331042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
    Fix a compilation error on gcc8 #3 0x0000000004ae725d llvm::APInt::countLeadingZerosSlowCase() const (/opt/compiler-explorer/clang-trunk/bin/opt+0x4ae725d)
    Fix a compilation error on gcc8 #4 0x0000000000ab63c4 instCombineSVECmpNE(llvm::InstCombiner&, llvm::IntrinsicInst&) AArch64TargetTransformInfo.cpp:0:0
    Seedarg/member/wip #5 0x0000000000abb563 llvm::AArch64TTIImpl::instCombineIntrinsic(llvm::InstCombiner&, llvm::IntrinsicInst&) const (/opt/compiler-explorer/clang-trunk/bin/opt+0xabb563)
    Add check for matching HeaderFilter before emitting Diagnostic #6 0x0000000003bb0eba llvm::InstCombinerImpl::visitCallInst(llvm::CallInst&) (/opt/compiler-explorer/clang-trunk/bin/opt+0x3bb0eba)
    Random engine swap #7 0x0000000003b56f4a llvm::InstCombinerImpl::run() (/opt/compiler-explorer/clang-trunk/bin/opt+0x3b56f4a)
    Update rwlock init #8 0x0000000003b58e53 combineInstructionsOverFunction(llvm::Function&, llvm::InstructionWorklist&, llvm::AAResults*, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::OptimizationRemarkEmitter&, llvm::BlockFrequencyInfo*, llvm::BranchProbabilityInfo*, llvm::ProfileSummaryInfo*, llvm::LoopInfo*, llvm::InstCombineOptions const&) (.isra.0) InstructionCombining.cpp:0:0
    Next80 merge test #9 0x0000000003b59b11 llvm::InstCombinePass::run(llvm::Function&, llvm::AnalysisManagerllvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/opt+0x3b59b11)
    Fix typo: 'soruce' -> 'source' #10 0x00000000029b047e llvm::detail::PassModel<llvm::Function, llvm::InstCombinePass, llvm::AnalysisManagerllvm::Function>::run(llvm::Function&, llvm::AnalysisManagerllvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/opt+0x29b047e)
    fix for gcc 8 #11 0x00000000049e1fb7 llvm::PassManager<llvm::Function, llvm::AnalysisManagerllvm::Function>::run(llvm::Function&, llvm::AnalysisManagerllvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/opt+0x49e1fb7)
    Fix "Allman" style example #12 0x0000000000d7dc2e llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManagerllvm::Function>, llvm::AnalysisManagerllvm::Function>::run(llvm::Function&, llvm::AnalysisManagerllvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/opt+0xd7dc2e)
    Defer diag #13 0x00000000049dc906 llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManagerllvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/opt+0x49dc906)
    WIP lifetime categories #14 0x0000000000d7d6fe llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManagerllvm::Module>::run(llvm::Module&, llvm::AnalysisManagerllvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/opt+0xd7d6fe)
    Fix ClangOpenCLBuiltinsImpl target not found #15 0x00000000049deec7 llvm::PassManager<llvm::Module, llvm::AnalysisManagerllvm::Module>::run(llvm::Module&, llvm::AnalysisManagerllvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/opt+0x49deec7)
    __unique_stable_name implementation. #16 0x00000000008f9928 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRefllvm::PassPlugin, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/opt+0x8f9928)
    Lockdown test #17 0x00000000008ede45 optMain (/opt/compiler-explorer/clang-trunk/bin/opt+0x8ede45)
    Lockdown test #18 0x00007fe331029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
    Test commit to check lockdown app #19 0x00007fe331029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
    Construct path using a locale #20 0x00000000008e625e _start (/opt/compiler-explorer/clang-trunk/bin/opt+0x8e625e)
    Program terminated with signal: SIGSEGV
    Compiler returned: 139`

@paulwalker-arm
Copy link
Collaborator

Sorry I really don't mean to be a pain here and I'll accept this version of the PR if you continue to see something different to me, but is it possible you're not using a debug or asserts build?

https://www.godbolt.org/z/8McfPMqTz shows the same error quite clearly.

@wuxie2022
Copy link

Sorry I really don't mean to be a pain here and I'll accept this version of the PR if you continue to see something different to me, but is it possible you're not using a debug or asserts build?

The result of https://www.godbolt.org/z/8McfPMqTz shows that the recommended case crashes when compiled with the debug version of the compiler, but it does not crash when compiled with the release version. On the other hand, the case I uploaded crashes even when compiled with the release version of the compiler. So what I don't understand is, if this case can only detect the crash error when compiled with the debug version of the compiler, is this case really meaningful? If I receive your confirmation, I will make the necessary changes. Once again, thank you for your review!

@paulwalker-arm
Copy link
Collaborator

Yes, having a test case that only exposes a failure when asserts are enable is legitimate and expected because all active LLVM development should be done when asserts are enabled, otherwise you're minimising your test coverage.

Whilst the other test case crashes with a release compiler today, a crash is inherently unexplained and so the same test might not crash in the future. For example, you already mention the need for -O2, which enables many code paths that are unrelated to the code you've fixed. The simpler test makes it clearer how the code is linked to the affected assert.

@wuxie2022
Copy link

Yes, having a test case that only exposes a failure when asserts are enable is legitimate and expected because all active LLVM development should be done when asserts are enabled, otherwise you're minimising your test coverage.

Whilst the other test case crashes with a release compiler today, a crash is inherently unexplained and so the same test might not crash in the future. For example, you already mention the need for -O2, which enables many code paths that are unrelated to the code you've fixed. The simpler test makes it clearer how the code is linked to the affected assert.

Thank you for your explanation. I will modify the case.

…eSVECmpNE.

Func instCombineSVECmpNE is used to identify specific pattern of instruction
'svecmene',
and then predict its result, use the result to replace instruction 'svecmene'.
The specific pattern can be descriped below:
1.The svecmpne must compare all elements of vec.
2.The svecmpne inst compare its ves with zero.
3.The vec in svecmpne inst is generated by inst dupqlane, and the copy
value of this dupqlane must be zero.
In NO.3 above, func instCombineSVECmpNE uses 'cast' to transform op1 of
dupqlane without checking if the cast is success, then generate a crash
in some situation.
@cceerczw cceerczw force-pushed the fix-instcombine-crash branch from 3771bbf to 902b0d3 Compare August 20, 2024 07:19
@cceerczw
Copy link
Contributor Author

Hi,@paulwalker-arm, thanks for the review again, can this patch merge?

@paulwalker-arm
Copy link
Collaborator

Hi,@paulwalker-arm, thanks for the review again, can this patch merge?

I see no reason why not. The windows failure looks unrelated to this work.

@cceerczw
Copy link
Contributor Author

Hi,@paulwalker-arm, thanks for the review again, can this patch merge?

I see no reason why not. The windows failure looks unrelated to this work.

yes, so can you help me to merge this patch?

@paulwalker-arm paulwalker-arm merged commit 67a9093 into llvm:main Aug 23, 2024
6 of 8 checks passed
cjdb pushed a commit to cjdb/llvm-project that referenced this pull request Aug 23, 2024
dmpolukhin pushed a commit to dmpolukhin/llvm-project that referenced this pull request Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants