[llvm] r240634 - [SystemZ] Only attempt RxSBG optimization for integer types
Ulrich Weigand
ulrich.weigand at de.ibm.com
Thu Jun 25 04:52:36 PDT 2015
Author: uweigand
Date: Thu Jun 25 06:52:36 2015
New Revision: 240634
URL: http://llvm.org/viewvc/llvm-project?rev=240634&view=rev
Log:
[SystemZ] Only attempt RxSBG optimization for integer types
As pointed out by Justin Bogner (see r240520), SystemZDAGToDAGISel::Select
currently attempts to convert boolean operations into RxSBG even on some
non-integer types (in particular, vector types). This would not work in
any case, and it happened to trigger undefined behaviour in allOnes.
This patch verifies that we have a (<= 64-bit) integer type before
attempting to perform this optimization.
Modified:
llvm/trunk/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
Modified: llvm/trunk/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp?rev=240634&r1=240633&r2=240634&view=diff
==============================================================================
--- llvm/trunk/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp Thu Jun 25 06:52:36 2015
@@ -96,6 +96,7 @@ struct SystemZAddressingMode {
// Return a mask with Count low bits set.
static uint64_t allOnes(unsigned int Count) {
+ assert(Count <= 64);
if (Count > 63)
return UINT64_MAX;
return (uint64_t(1) << Count) - 1;
@@ -905,6 +906,8 @@ SDValue SystemZDAGToDAGISel::convertTo(S
SDNode *SystemZDAGToDAGISel::tryRISBGZero(SDNode *N) {
SDLoc DL(N);
EVT VT = N->getValueType(0);
+ if (!VT.isInteger() || VT.getSizeInBits() > 64)
+ return nullptr;
RxSBGOperands RISBG(SystemZ::RISBG, SDValue(N, 0));
unsigned Count = 0;
while (expandRxSBG(RISBG))
@@ -960,6 +963,10 @@ SDNode *SystemZDAGToDAGISel::tryRISBGZer
}
SDNode *SystemZDAGToDAGISel::tryRxSBG(SDNode *N, unsigned Opcode) {
+ SDLoc DL(N);
+ EVT VT = N->getValueType(0);
+ if (!VT.isInteger() || VT.getSizeInBits() > 64)
+ return nullptr;
// Try treating each operand of N as the second operand of the RxSBG
// and see which goes deepest.
RxSBGOperands RxSBG[] = {
@@ -995,8 +1002,6 @@ SDNode *SystemZDAGToDAGISel::tryRxSBG(SD
Opcode = SystemZ::RISBGN;
}
- SDLoc DL(N);
- EVT VT = N->getValueType(0);
SDValue Ops[5] = {
convertTo(DL, MVT::i64, Op0),
convertTo(DL, MVT::i64, RxSBG[I].Input),
More information about the llvm-commits
mailing list