This patch fixes a crash in `tryVPTERNLOG` when trying to peel out the outer not in cases like `~(A | B | C)`. Previously, `InnerOp` was taken directly from `Op->getOperand(0)` before verifying that it was a logical operation. As a result, the code could later access `InnerOp->getOperand(0)` or `InnerOp->getOperand(1)` even when `InnerOp` was something like a bitcast, causing an error. This patch applies `getFoldableLogicOp` to `InnerOp`, ensuring that `InnerOp` is a valid logic operation before it is dereferenced.
26 lines
951 B
LLVM
26 lines
951 B
LLVM
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
|
|
; RUN: llc < %s -mtriple=x86_64-- -mattr=+avx512f,+avx512vl | FileCheck %s --check-prefixes=CHECK
|
|
|
|
define <8 x i64> @foo(<8 x i64> %a, <8 x i64> %b, <8 x i64> %c) {
|
|
; CHECK-LABEL: foo:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: vpternlogq {{.*#+}} zmm0 = ~(zmm0 | zmm2 | zmm1)
|
|
; CHECK-NEXT: retq
|
|
%and.demorgan = or <8 x i64> %b, %a
|
|
%and3.demorgan = or <8 x i64> %and.demorgan, %c
|
|
%and3 = xor <8 x i64> %and3.demorgan, splat (i64 -1)
|
|
ret <8 x i64> %and3
|
|
}
|
|
|
|
define <8 x i64> @xorbitcast(<64 x i8> %a, <64 x i8> %b, <64 x i8> %c) {
|
|
; CHECK-LABEL: xorbitcast:
|
|
; CHECK: # %bb.0:
|
|
; CHECK-NEXT: vpternlogq {{.*#+}} zmm0 = ~(zmm0 | zmm2 | zmm1)
|
|
; CHECK-NEXT: retq
|
|
%or1 = or <64 x i8> %a, %b
|
|
%or2 = or <64 x i8> %or1, %c
|
|
%cast = bitcast <64 x i8> %or2 to <8 x i64>
|
|
%xor = xor <8 x i64> %cast, splat (i64 -1)
|
|
ret <8 x i64> %xor
|
|
}
|