summaryrefslogtreecommitdiff
path: root/gcc/config/i386/i386.md
diff options
context:
space:
mode:
authoruros <uros@138bc75d-0d04-0410-961f-82ee72b054a4>2012-05-06 23:07:38 +0000
committeruros <uros@138bc75d-0d04-0410-961f-82ee72b054a4>2012-05-06 23:07:38 +0000
commitf1cb261b0d5cb297f6cfb07ff89f6f3c76cd9a7b (patch)
treed0d1e86845c6acfe590e0fb217cd68dde6d90e4f /gcc/config/i386/i386.md
parenta846db2ca688b1fe633b71262ef608a17cd8f993 (diff)
downloadgcc-f1cb261b0d5cb297f6cfb07ff89f6f3c76cd9a7b.tar.gz
* config/i386/i386.md (ctz<mode>2): Emit rep;bsf even for !TARGET_BMI.
Emit bsf when optimizing for size. (*ffs<mode>_1): Ditto. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@187219 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/config/i386/i386.md')
-rw-r--r--gcc/config/i386/i386.md30
1 files changed, 25 insertions, 5 deletions
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index 360bd32b9ab..b78054fd549 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -12112,9 +12112,22 @@
(set (match_operand:SWI48 0 "register_operand" "=r")
(ctz:SWI48 (match_dup 1)))]
""
- "bsf{<imodesuffix>}\t{%1, %0|%0, %1}"
+{
+ if (optimize_function_for_size_p (cfun))
+ return "bsf{<imodesuffix>}\t{%1, %0|%0, %1}";
+ else if (TARGET_BMI)
+ return "tzcnt{<imodesuffix>}\t{%1, %0|%0, %1}";
+ else
+ /* tzcnt expands to rep;bsf and we can use it even if !TARGET_BMI. */
+ return "rep; bsf{<imodesuffix>}\t{%1, %0|%0, %1}";
+}
[(set_attr "type" "alu1")
(set_attr "prefix_0f" "1")
+ (set (attr "prefix_rep")
+ (if_then_else
+ (match_test "optimize_function_for_size_p (cfun)")
+ (const_string "0")
+ (const_string "1")))
(set_attr "mode" "<MODE>")])
(define_insn "ctz<mode>2"
@@ -12123,14 +12136,21 @@
(clobber (reg:CC FLAGS_REG))]
""
{
- if (TARGET_BMI)
- return "tzcnt{<imodesuffix>}\t{%1, %0|%0, %1}";
- else
+ if (optimize_function_for_size_p (cfun))
return "bsf{<imodesuffix>}\t{%1, %0|%0, %1}";
+ else if (TARGET_BMI)
+ return "tzcnt{<imodesuffix>}\t{%1, %0|%0, %1}";
+ else
+ /* tzcnt expands to rep;bsf and we can use it even if !TARGET_BMI. */
+ return "rep; bsf{<imodesuffix>}\t{%1, %0|%0, %1}";
}
[(set_attr "type" "alu1")
(set_attr "prefix_0f" "1")
- (set (attr "prefix_rep") (symbol_ref "TARGET_BMI"))
+ (set (attr "prefix_rep")
+ (if_then_else
+ (match_test "optimize_function_for_size_p (cfun)")
+ (const_string "0")
+ (const_string "1")))
(set_attr "mode" "<MODE>")])
(define_expand "clz<mode>2"