CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Search found 4 matches
CCS Forum Index
Author Message
  Topic: int1 = val&1 optimization possible?
matt.dawson

Replies: 8
Views: 10557

PostForum: General CCS C Discussion   Posted: Fri Oct 31, 2014 2:55 am   Subject: int1 = val&1 optimization possible?
In "a & 1", 1 is a constant.
Optimized paths don't have to handle everything, they are chosen based upon the specific code written.
  Topic: int1 = val&1 optimization possible?
matt.dawson

Replies: 8
Views: 10557

PostForum: General CCS C Discussion   Posted: Fri Oct 31, 2014 2:32 am   Subject: int1 = val&1 optimization possible?
Yes I understand why it's done in the generic case.
The case I'm talking about is an optimization for when the last operation in an expression is a constant and of 1.
It isn't hard to detect that in ...
  Topic: int1 = val&1 optimization possible?
matt.dawson

Replies: 8
Views: 10557

PostForum: General CCS C Discussion   Posted: Thu Oct 30, 2014 10:19 pm   Subject: int1 = val&1 optimization possible?
That's exactly it.
I've tested this in PCM Compiler v5.030, compiling at optimisation level 9 and it generates the same extra bit clears, tests and sets.


#include <16LF1705.h>

void main ...
  Topic: int1 = val&1 optimization possible?
matt.dawson

Replies: 8
Views: 10557

PostForum: General CCS C Discussion   Posted: Thu Oct 30, 2014 8:14 pm   Subject: int1 = val&1 optimization possible?
I notice in my code that this compiles to:
.................... int1 b = (crc & 1);
17E4: MOVF 27,W
17E5: ANDLW 01
17E6: MOVWF 77
17E7: CLRF 7A
17E8: BCF 29.0
17E9 ...
 
Page 1 of 1
All times are GMT - 6 Hours
Jump to:  


Powered by phpBB © 2001, 2005 phpBB Group