From fbed0ac56b2797e9c91e08bbb7d4d5121e92ee3d Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Wed, 9 May 2012 10:31:53 -0700 Subject: [PATCH] Remove allOffMaskIsSafe from Target The intent of this was to indicate whether it was safe to run code with an 'all of' mask on the given target (and then sometimes be more flexible about e.g. running both true and false blocks of if statements, etc.) The problem is that even if the architecture has full native mask support, it's still not safe to run 'uniform' memory operations with the mask all off. Even more tricky, we sometimes transform masked varying memory operations to uniform ones during optimization (e.g. gather->load and broadcast). This fixes a number of the tests/switch-* tests that were failing on the generic targets due to this issue. --- ast.cpp | 5 ----- ispc.cpp | 13 ------------- ispc.h | 6 ------ 3 files changed, 24 deletions(-) diff --git a/ast.cpp b/ast.cpp index 1bf00a0e..96c41616 100644 --- a/ast.cpp +++ b/ast.cpp @@ -395,11 +395,6 @@ lCheckAllOffSafety(ASTNode *node, void *data) { return false; } - if (g->target.allOffMaskIsSafe == true) - // Don't worry about memory accesses if we have a target that can - // safely run them with the mask all off - return true; - IndexExpr *ie; if ((ie = dynamic_cast(node)) != NULL && ie->baseExpr != NULL) { const Type *type = ie->baseExpr->GetType(); diff --git a/ispc.cpp b/ispc.cpp index 9d1220d5..05ca7c07 100644 --- a/ispc.cpp +++ b/ispc.cpp @@ -206,7 +206,6 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa, t->vectorWidth = 4; t->attributes = "+sse,+sse2,-sse3,-sse41,-sse42,-sse4a,-ssse3,-popcnt"; t->maskingIsFree = false; - t->allOffMaskIsSafe = false; t->maskBitCount = 32; } else if (!strcasecmp(isa, "sse2-x2")) { @@ -215,7 +214,6 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa, t->vectorWidth = 8; t->attributes = "+sse,+sse2,-sse3,-sse41,-sse42,-sse4a,-ssse3,-popcnt"; t->maskingIsFree = false; - t->allOffMaskIsSafe = false; t->maskBitCount = 32; } else if (!strcasecmp(isa, "sse4")) { @@ -224,7 +222,6 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa, t->vectorWidth = 4; t->attributes = "+sse,+sse2,+sse3,+sse41,-sse42,-sse4a,+ssse3,-popcnt,+cmov"; t->maskingIsFree = false; - t->allOffMaskIsSafe = false; t->maskBitCount = 32; } else if (!strcasecmp(isa, "sse4x2") || !strcasecmp(isa, "sse4-x2")) { @@ -233,7 +230,6 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa, t->vectorWidth = 8; t->attributes = "+sse,+sse2,+sse3,+sse41,-sse42,-sse4a,+ssse3,-popcnt,+cmov"; t->maskingIsFree = false; - t->allOffMaskIsSafe = false; t->maskBitCount = 32; } else if (!strcasecmp(isa, "generic-4")) { @@ -241,7 +237,6 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa, t->nativeVectorWidth = 4; t->vectorWidth = 4; t->maskingIsFree = true; - t->allOffMaskIsSafe = true; t->maskBitCount = 1; } else if (!strcasecmp(isa, "generic-8")) { @@ -249,7 +244,6 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa, t->nativeVectorWidth = 8; t->vectorWidth = 8; t->maskingIsFree = true; - t->allOffMaskIsSafe = true; t->maskBitCount = 1; } else if (!strcasecmp(isa, "generic-16")) { @@ -257,7 +251,6 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa, t->nativeVectorWidth = 16; t->vectorWidth = 16; t->maskingIsFree = true; - t->allOffMaskIsSafe = true; t->maskBitCount = 1; t->hasHalf = true; t->hasTranscendentals = true; @@ -267,7 +260,6 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa, t->nativeVectorWidth = 32; t->vectorWidth = 32; t->maskingIsFree = true; - t->allOffMaskIsSafe = true; t->maskBitCount = 1; t->hasHalf = true; t->hasTranscendentals = true; @@ -277,7 +269,6 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa, t->nativeVectorWidth = 1; t->vectorWidth = 1; t->maskingIsFree = false; - t->allOffMaskIsSafe = false; t->maskBitCount = 32; } else if (!strcasecmp(isa, "avx")) { @@ -286,7 +277,6 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa, t->vectorWidth = 8; t->attributes = "+avx,+popcnt,+cmov"; t->maskingIsFree = false; - t->allOffMaskIsSafe = false; t->maskBitCount = 32; } else if (!strcasecmp(isa, "avx-x2")) { @@ -295,7 +285,6 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa, t->vectorWidth = 16; t->attributes = "+avx,+popcnt,+cmov"; t->maskingIsFree = false; - t->allOffMaskIsSafe = false; t->maskBitCount = 32; } #ifndef LLVM_3_0 @@ -305,7 +294,6 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa, t->vectorWidth = 8; t->attributes = "+avx2,+popcnt,+cmov,+f16c"; t->maskingIsFree = false; - t->allOffMaskIsSafe = false; t->maskBitCount = 32; t->hasHalf = true; } @@ -315,7 +303,6 @@ Target::GetTarget(const char *arch, const char *cpu, const char *isa, t->vectorWidth = 16; t->attributes = "+avx2,+popcnt,+cmov,+f16c"; t->maskingIsFree = false; - t->allOffMaskIsSafe = false; t->maskBitCount = 32; t->hasHalf = true; } diff --git a/ispc.h b/ispc.h index e2d9294d..bd170936 100644 --- a/ispc.h +++ b/ispc.h @@ -239,12 +239,6 @@ struct Target { natively. */ bool maskingIsFree; - /** Is it safe to run code with the mask all if: e.g. on SSE, the fast - gather trick assumes that at least one program instance is running - (so that it can safely assume that the array base pointer is - valid). */ - bool allOffMaskIsSafe; - /** How many bits are used to store each element of the mask: e.g. this is 32 on SSE/AVX, since that matches the HW better, but it's 1 for the generic target. */